mirror of
https://github.com/moparisthebest/Simba
synced 2025-01-11 21:58:23 -05:00
Added the loaded char names as constants to the Scripting engine (dynamically).
Also replaced all the Bitmaps.Bmp[index] with bitmaps[index]. Creaded MaskFromText, named the others BitmapFromText and TPAFromText. Added a GetFontByIndex to the FontLoader. git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@459 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
parent
691bddcde6
commit
1fb4a6d44a
@ -22,7 +22,7 @@
|
||||
}
|
||||
function GetMufasaBitmap(bmp : integer): TMufasaBitmap;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.Bmp[bmp];
|
||||
result := CurrThread.Client.MBitmaps[bmp];
|
||||
end;
|
||||
|
||||
function CreateBitmap(w,h : integer):integer;
|
||||
@ -37,7 +37,7 @@ end;
|
||||
|
||||
procedure SaveBitmap(Bmp : integer; path : string);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].SaveToFile(Path);
|
||||
CurrThread.Client.MBitmaps[Bmp].SaveToFile(Path);
|
||||
end;
|
||||
|
||||
function BitmapFromString(Width,height : integer; Data : string) : integer;
|
||||
@ -53,7 +53,7 @@ end;
|
||||
procedure SetBitmapSize(Bmp,NewW,NewH : integer);
|
||||
begin;
|
||||
if (NewW>=0) and (NewH >=0) then
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].SetSize(NewW,NewH)
|
||||
CurrThread.Client.MBitmaps[Bmp].SetSize(NewW,NewH)
|
||||
else
|
||||
raise exception.createfmt('Wrong Width or Height in SetBitmapSize: (%d,%d)',[NewW,NewH]);
|
||||
end;
|
||||
@ -61,14 +61,14 @@ end;
|
||||
procedure StretchBitmapResize(Bmp,NewW,NewH : integer);
|
||||
begin;
|
||||
if (NewW>=0) and (NewH >=0) then
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].StretchResize(NewW,NewH)
|
||||
CurrThread.Client.MBitmaps[Bmp].StretchResize(NewW,NewH)
|
||||
else
|
||||
raise exception.createfmt('Wrong Width or Height in ScretchResize: (%d,%d)',[NewW,NewH]);
|
||||
end;
|
||||
|
||||
procedure GetBitmapSize(Bmp : integer; out BmpW,BmpH : integer);
|
||||
begin;
|
||||
With CurrThread.Client.MBitmaps.Bmp[bmp] do
|
||||
With CurrThread.Client.MBitmaps[bmp] do
|
||||
begin;
|
||||
BmpW := width;
|
||||
BmpH := Height;
|
||||
@ -77,7 +77,7 @@ end;
|
||||
|
||||
procedure SetBitmapName(Bmp : integer; name : string);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].BmpName:= name;
|
||||
CurrThread.Client.MBitmaps[Bmp].BmpName:= name;
|
||||
end;
|
||||
|
||||
function CreateMirroredBitmap(Bmp : integer) : integer;
|
||||
@ -92,61 +92,61 @@ end;
|
||||
|
||||
function FastGetPixel(bmp,x,y : integer) : LongWord;
|
||||
begin;
|
||||
Result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixel(x,y);
|
||||
Result := CurrThread.Client.MBitmaps[Bmp].FastGetPixel(x,y);
|
||||
end;
|
||||
|
||||
function FastGetPixels(bmp : integer; TPA : TPointArray) : TIntegerArray;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.Bmp[Bmp].FastGetPixels(TPA);
|
||||
result := CurrThread.Client.MBitmaps[Bmp].FastGetPixels(TPA);
|
||||
end;
|
||||
|
||||
procedure FastSetPixel(Bmp,x,y : integer; Color : TColor);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[bmp].FastSetPixel(x,y,color);
|
||||
CurrThread.Client.MBitmaps[bmp].FastSetPixel(x,y,color);
|
||||
end;
|
||||
|
||||
procedure FastSetPixels(Bmp : integer; TPA : TPointArray; Colors : TIntegerArray);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].FastSetPixels(TPA,Colors);
|
||||
CurrThread.Client.MBitmaps[Bmp].FastSetPixels(TPA,Colors);
|
||||
end;
|
||||
|
||||
procedure DrawTPABitmap(bitmap : integer; TPA : TPointArray; Color : integer);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[Bitmap].DrawTPA(TPA,Color);
|
||||
CurrThread.Client.MBitmaps[Bitmap].DrawTPA(TPA,Color);
|
||||
end;
|
||||
procedure DrawATPABitmap(bitmap : integer; ATPA : T2DPointArray);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[bitmap].DrawATPA(ATPA);
|
||||
CurrThread.Client.MBitmaps[bitmap].DrawATPA(ATPA);
|
||||
end;
|
||||
|
||||
procedure DrawATPABitmapEx(bitmap : integer; ATPA : T2DPointArray; Colors : TIntegerArray);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[bitmap].DrawATPA(ATPA,Colors);
|
||||
CurrThread.Client.MBitmaps[bitmap].DrawATPA(ATPA,Colors);
|
||||
end;
|
||||
|
||||
procedure FastDrawClear(bmp : integer; Color : TColor);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[bmp].FastDrawClear(Color);
|
||||
CurrThread.Client.MBitmaps[bmp].FastDrawClear(Color);
|
||||
end;
|
||||
|
||||
procedure FastDrawTransparent(x, y: Integer; SourceBitmap, TargetBitmap: Integer);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[SourceBitmap].FastDrawTransparent(x,y,CurrThread.Client.MBitmaps.Bmp[TargetBitmap]);
|
||||
CurrThread.Client.MBitmaps[SourceBitmap].FastDrawTransparent(x,y,CurrThread.Client.MBitmaps[TargetBitmap]);
|
||||
end;
|
||||
|
||||
procedure SetTransparentColor(Bmp : integer; Color : TColor);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].SetTransparentColor(Color);
|
||||
CurrThread.Client.MBitmaps[Bmp].SetTransparentColor(Color);
|
||||
end;
|
||||
|
||||
function GetTransparentColor(Bmp : integer) : TColor;
|
||||
begin;
|
||||
Result := CurrThread.Client.MBitmaps.Bmp[bmp].GetTransparentColor;
|
||||
Result := CurrThread.Client.MBitmaps[bmp].GetTransparentColor;
|
||||
end;
|
||||
|
||||
procedure FastReplaceColor(bmp: Integer; OldColor, NewColor: TColor);
|
||||
begin
|
||||
CurrThread.Client.MBitmaps.Bmp[Bmp].FastReplaceColor(OldColor,NewColor);
|
||||
CurrThread.Client.MBitmaps[Bmp].FastReplaceColor(OldColor,NewColor);
|
||||
end;
|
||||
|
||||
procedure ps_CopyClientToBitmap(bmp, xs, ys, xe, ye: Integer);
|
||||
@ -157,44 +157,44 @@ end;
|
||||
function BitmapFromClient(const xs, ys, xe, ye: Integer): Integer;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.CreateBMP(0,0);
|
||||
CurrThread.Client.MBitmaps.Bmp[result].CopyClientToBitmap(CurrThread.Client.IOManager,True,xs,ys,xe,ye);
|
||||
CurrThread.Client.MBitmaps[result].CopyClientToBitmap(CurrThread.Client.IOManager,True,xs,ys,xe,ye);
|
||||
end;
|
||||
|
||||
function FindBitmap(Bitmap: integer; out x, y: Integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmap( MBitmaps.Bmp[bitmap],x,y);
|
||||
result := MFinder.FindBitmap( MBitmaps[bitmap],x,y);
|
||||
end;
|
||||
|
||||
function FindBitmapIn(bitmap: integer; out x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapIn( MBitmaps.Bmp[bitmap],x,y,xs,ys,xe,ye);
|
||||
result := MFinder.FindBitmapIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye);
|
||||
end;
|
||||
|
||||
function FindBitmapToleranceIn(bitmap: integer; out x, y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapToleranceIn( MBitmaps.Bmp[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
||||
result := MFinder.FindBitmapToleranceIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
||||
end;
|
||||
|
||||
|
||||
function FindBitmapSpiral(bitmap: Integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapSpiral(Mbitmaps.bmp[bitmap],x,y,xs,ys,xe,ye);
|
||||
result := MFinder.FindBitmapSpiral(Mbitmaps[bitmap],x,y,xs,ys,xe,ye);
|
||||
end;
|
||||
|
||||
function FindBitmapsSpiralTolerance(bitmap: integer; x, y: Integer; out Points : TPointArray; xs, ys, xe, ye,tolerance: Integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapsSpiralTolerance(MBitmaps.Bmp[bitmap],x,y,points,xs,ys,xe,ye,tolerance);
|
||||
result := MFinder.FindBitmapsSpiralTolerance(MBitmaps[bitmap],x,y,points,xs,ys,xe,ye,tolerance);
|
||||
end;
|
||||
|
||||
function FindBitmapSpiralTolerance(bitmap: integer; var x, y: Integer; xs, ys, xe, ye,tolerance : integer): Boolean;
|
||||
begin;
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapSpiralTolerance(MBitmaps.Bmp[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
||||
result := MFinder.FindBitmapSpiralTolerance(MBitmaps[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
||||
end;
|
||||
|
||||
function RotateBitmap(bitmap: Integer; angle: Extended): Integer;
|
||||
@ -216,7 +216,7 @@ begin;
|
||||
end;
|
||||
procedure InvertBitmap(Bitmap : integer);
|
||||
begin;
|
||||
CurrThread.Client.MBitmaps.Bmp[Bitmap].Invert;
|
||||
CurrThread.Client.MBitmaps[Bitmap].Invert;
|
||||
end;
|
||||
function CopyBitmap(Bitmap : integer) : integer;
|
||||
begin;
|
||||
@ -255,25 +255,25 @@ begin;
|
||||
Bmp[bitmap].Posterize(Bmp[result],po);
|
||||
end;
|
||||
end;
|
||||
function CreateBitmapMask(Bitmap : integer) : TMask;
|
||||
function CreateMaskFromBitmap(Bitmap : integer) : TMask;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.Bmp[Bitmap].CreateTMask;
|
||||
result := CurrThread.Client.MBitmaps[Bitmap].CreateTMask;
|
||||
end;
|
||||
|
||||
function FindMaskTolerance(mask: TMask; out x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;
|
||||
begin;
|
||||
result := CurrThread.Client.MFinder.FindBitmapMaskTolerance(Mask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
||||
result := CurrThread.Client.MFinder.FindMaskTolerance(Mask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
||||
end;
|
||||
function FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;
|
||||
begin;
|
||||
Writeln('Better be using FindMaskTolerance in combination with CreateBitmapMask, more efficient.');
|
||||
psWriteln('Better be using FindMaskTolerance in combination with CreateMaskFromBitmap, more efficient.');
|
||||
with CurrThread.Client do
|
||||
result := MFinder.FindBitmapMaskTolerance(MBitmaps.bmp[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
||||
result := MFinder.FindMaskTolerance(MBitmaps[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
||||
end;
|
||||
|
||||
function FindDeformedBitmapToleranceIn(bitmap: integer; out x,
|
||||
y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer; Range: Integer;
|
||||
AllowPartialAccuracy: Boolean; out accuracy: Extended): Boolean;
|
||||
begin;
|
||||
result := CurrThread.Client.MFinder.FindDeformedBitmapToleranceIn(CurrThread.Client.MBitmaps.bmp[Bitmap],x,y,xs,ys,xe,ye,tolerance,range,AllowPartialAccuracy,accuracy);
|
||||
result := CurrThread.Client.MFinder.FindDeformedBitmapToleranceIn(CurrThread.Client.MBitmaps[Bitmap],x,y,xs,ys,xe,ye,tolerance,range,AllowPartialAccuracy,accuracy);
|
||||
end;
|
||||
|
@ -3,7 +3,7 @@ begin
|
||||
Result := CurrThread.Client.MOCR.GetUpTextAtEx(7, 7, true);
|
||||
end;
|
||||
|
||||
function BitmapFromTextFont(text, font: String): integer;
|
||||
function BitmapFromText(text, font: String): integer;
|
||||
var
|
||||
bmp: TMufasaBitmap;
|
||||
begin
|
||||
@ -12,8 +12,12 @@ begin
|
||||
Result := CurrThread.Client.MBitmaps.AddBMP(bmp);
|
||||
end;
|
||||
|
||||
function TPAFromTextFont(text, font: String): TPointArray;
|
||||
function MaskFromText(text, font: String): TMask;
|
||||
begin
|
||||
Result := CurrThread.Client.MOCR.TextToMask(text,font);
|
||||
end;
|
||||
|
||||
function TPAFromText(text, font: String): TPointArray;
|
||||
var
|
||||
w,h : integer;
|
||||
begin
|
||||
|
@ -86,14 +86,14 @@ end;
|
||||
|
||||
procedure DrawBitmapDebugImg(bmp : integer);
|
||||
begin;
|
||||
CurrThread.DebugImg.ToDrawBitmap^ := CurrThread.Client.MBitmaps.Bmp[bmp];
|
||||
CurrThread.DebugImg.ToDrawBitmap^ := CurrThread.Client.MBitmaps[bmp];
|
||||
CurrThread.Synchronize(CurrThread.DebugImg.DrawBitmap);
|
||||
end;
|
||||
|
||||
function GetDebugBitmap : integer;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.CreateBMP(0,0);
|
||||
CurrThread.DebugImg.GetDebugBitmap^ := CurrThread.Client.MBitmaps.Bmp[result];
|
||||
CurrThread.DebugImg.GetDebugBitmap^ := CurrThread.Client.MBitmaps[result];
|
||||
CurrThread.Synchronize(CurrThread.DebugImg.GetBitmap);
|
||||
end;
|
||||
|
||||
|
@ -33,7 +33,7 @@ end;
|
||||
|
||||
procedure SetTargetBitmap(bitmap: Integer);
|
||||
begin;
|
||||
CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps.Bmp[Bitmap]);
|
||||
CurrThread.Client.IOManager.SetTarget(CurrThread.Client.MBitmaps[Bitmap]);
|
||||
end;
|
||||
|
||||
procedure GetClientDimensions(out w, h: integer);
|
||||
|
@ -173,9 +173,9 @@ AddFunction(@isKeyDown, 'function IsKeyDown(key: Word): Boolean;');
|
||||
{ OCR}
|
||||
SetCurrSection('OCR');
|
||||
AddFunction(@rs_GetUpText, 'function rs_GetUpText: string;');
|
||||
AddFunction(@BitmapFromTextFont, 'function BitmapFromTextFont(text, font: String): integer;');
|
||||
AddFunction(@TPAFromTextFont, 'function TPAFromTextFont(text, font: String): TPointArray;');
|
||||
|
||||
AddFunction(@BitmapFromText, 'function BitmapFromText(text, font: String): integer;');
|
||||
AddFunction(@TPAFromText, 'function TPAFromText(text, font: String): TPointArray;');
|
||||
AddFunction(@MaskFromText, 'function MaskFromText(text, font: String): TMask;');
|
||||
|
||||
{Bitmaps}
|
||||
SetCurrSection('Bitmaps');
|
||||
@ -216,7 +216,7 @@ AddFunction(@GreyScaleBitmap,'function GreyScaleBitmap(bitmap : integer) : integ
|
||||
AddFunction(@BrightnessBitmap,'function BrightnessBitmap(Bitmap,br : integer) : integer;');
|
||||
AddFunction(@ContrastBitmap,'function ContrastBitmap(bitmap : integer; co : extended) : integer;');
|
||||
AddFunction(@PosterizeBitmap,'function PosterizeBitmap(Bitmap : integer; po : integer) : integer;');
|
||||
AddFunction(@CreateBitmapMask,'function CreateBitmapMask(Bitmap : integer) : TMask;');
|
||||
AddFunction(@CreateMaskFromBitmap,'function CreateMaskFromBitmap(Bitmap : integer) : TMask;');
|
||||
AddFunction(@FindMaskTolerance,'function FindMaskTolerance(mask: TMask; out x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;');
|
||||
AddFunction(@FindBitmapMaskTolerance,'function FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;');
|
||||
AddFunction(@FindDeformedBitmapToleranceIn,'function FindDeformedBitmapToleranceIn(bitmap: integer; out x,y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer; Range: Integer; AllowPartialAccuracy: Boolean; out accuracy: Extended): Boolean;');
|
||||
|
@ -128,6 +128,7 @@ uses
|
||||
uPSC_std, uPSC_controls,uPSC_classes,uPSC_graphics,uPSC_stdctrls,uPSC_forms,
|
||||
uPSC_extctrls, //Compile-libs
|
||||
uPSUtils,
|
||||
fontloader,
|
||||
uPSR_std, uPSR_controls,uPSR_classes,uPSR_graphics,uPSR_stdctrls,uPSR_forms,
|
||||
uPSR_extctrls, //Runtime-libs
|
||||
Graphics, //For Graphics types
|
||||
@ -327,8 +328,12 @@ end;
|
||||
procedure TMMLPSThread.OnCompile(Sender: TPSScript);
|
||||
var
|
||||
i,ii : integer;
|
||||
Fonts : TMFonts;
|
||||
begin
|
||||
{$I PSInc/pscompile.inc}
|
||||
Fonts := Client.MOCR.GetFonts;
|
||||
for i := fonts.count - 1 downto 0 do
|
||||
PSScript.Comp.AddConstantN(Fonts[i].Name,'string').SetString(Fonts[i].Name);
|
||||
|
||||
for i := high(PluginsToLoad) downto 0 do
|
||||
for ii := 0 to PluginsGlob.MPlugins[PluginsToLoad[i]].MethodLen - 1 do
|
||||
@ -391,7 +396,8 @@ end;
|
||||
|
||||
function CreateMufasaBitmap : TMufasaBitmap;
|
||||
begin;
|
||||
result := CurrThread.Client.MBitmaps.Bmp[ CurrThread.Client.MBitmaps.CreateBMP(0,0)];
|
||||
result := TMufasaBitmap.Create;
|
||||
CurrThread.Client.MBitmaps.AddBMP(result);
|
||||
end;
|
||||
|
||||
procedure FreeMufasaBitmap(Self : TMufasaBitmap);
|
||||
|
@ -99,7 +99,7 @@ type
|
||||
function GetNewIndex : integer;
|
||||
public
|
||||
function GetBMP(Index : integer) : TMufasaBitmap;
|
||||
property Bmp[Index : integer]: TMufasaBitmap read GetBMP;
|
||||
property Bmp[Index : integer]: TMufasaBitmap read GetBMP; default;
|
||||
function CreateBMP(w, h: integer): Integer;
|
||||
function AddBMP(_bmp: TMufasaBitmap): Integer;
|
||||
function CopyBMP( Bitmap : integer) : Integer;
|
||||
@ -1038,9 +1038,8 @@ begin
|
||||
SetLength(result.White,w*h);
|
||||
dX := w-1;
|
||||
dY := h-1;
|
||||
//Search it like | | | | | instead of horizontal -> for X loop first.
|
||||
for x := 0 to dX do
|
||||
for y := 0 to dY do
|
||||
for y := 0 to dY do
|
||||
for x := 0 to dX do
|
||||
//Check for non-white/black pixels? Not for now atleast.
|
||||
if FData[y*w+x].r = 255 then
|
||||
begin;
|
||||
|
@ -69,7 +69,7 @@ type
|
||||
function FindColoredArea(var x, y: Integer; color, xs, ys, xe, ye: Integer; MinArea: Integer): Boolean;
|
||||
function FindColoredAreaTolerance(var x, y: Integer; color, xs, ys, xe, ye: Integer; MinArea, tol: Integer): Boolean;
|
||||
//Mask
|
||||
function FindBitmapMaskTolerance(mask: TMask; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;
|
||||
function FindMaskTolerance(mask: TMask; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;
|
||||
procedure CheckMask(Mask : TMask);
|
||||
//Bitmap functions
|
||||
function FindBitmap(bitmap: TMufasaBitmap; out x, y: Integer): Boolean;
|
||||
@ -1252,7 +1252,7 @@ end;
|
||||
{ Only works with CTS 1 for now.. Since Colorsame doesn't return a boolean :-( }
|
||||
//We do not check whether every white pixel is in tol range with every other white pixel..
|
||||
|
||||
function TMFinder.FindBitmapMaskTolerance(mask: TMask; out x, y: Integer; xs,
|
||||
function TMFinder.FindMaskTolerance(mask: TMask; out x, y: Integer; xs,
|
||||
ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean;
|
||||
var
|
||||
MainRowdata : TPRGB32Array;
|
||||
|
@ -48,23 +48,29 @@ type
|
||||
|
||||
|
||||
type
|
||||
|
||||
{ TMFonts }
|
||||
|
||||
TMFonts = class(TObject)
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
private
|
||||
function GetFontIndex(Name: String): Integer;
|
||||
function GetFontByIndex(Index : integer): TMfont;
|
||||
private
|
||||
Fonts: TList;
|
||||
Path: String;
|
||||
public
|
||||
constructor Create;
|
||||
destructor Destroy; override;
|
||||
|
||||
function GetFont(Name: String): TOcrData;
|
||||
function FreeFont(Name: String): boolean;
|
||||
function LoadFont(Name: String; Shadow: Boolean): boolean;
|
||||
procedure SetPath(aPath: String);
|
||||
function GetPath: String;
|
||||
|
||||
function Copy: TMFonts;
|
||||
private
|
||||
function GetFontIndex(Name: String): Integer;
|
||||
private
|
||||
Fonts: TList;
|
||||
Path: String;
|
||||
end;
|
||||
function GetFont(Name: String): TOcrData;
|
||||
function FreeFont(Name: String): boolean;
|
||||
function LoadFont(Name: String; Shadow: Boolean): boolean;
|
||||
procedure SetPath(aPath: String);
|
||||
function GetPath: String;
|
||||
function Copy: TMFonts;
|
||||
function Count : integer;
|
||||
property Font[Index : integer]: TMfont read GetFontByIndex; default;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
@ -126,6 +132,11 @@ begin
|
||||
Result.Data.outputs := Self.Data.outputs;
|
||||
end;
|
||||
|
||||
function TMFonts.GetFontByIndex(Index : integer): TMfont;
|
||||
begin
|
||||
result := TMfont(Fonts.Items[index]);
|
||||
end;
|
||||
|
||||
constructor TMFonts.Create;
|
||||
|
||||
begin
|
||||
@ -221,5 +232,10 @@ begin
|
||||
Result.Fonts.Add(TMFont(Self.Fonts.Items[i]).Copy());
|
||||
end;
|
||||
|
||||
function TMFonts.Count: integer;
|
||||
begin
|
||||
result := Fonts.Count;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -34,6 +34,9 @@ uses
|
||||
{End To-Remove unit}
|
||||
|
||||
type
|
||||
|
||||
{ TMOCR }
|
||||
|
||||
TMOCR = class(TObject)
|
||||
constructor Create(Owner: TObject);
|
||||
destructor Destroy; override;
|
||||
@ -54,6 +57,7 @@ uses
|
||||
function GetTextAt(atX, atY, font, minspacing, maxspacing, color, len: integer): string;
|
||||
function TextToFontTPA(Text, font: String; var w, h: integer): TPointArray;
|
||||
function TextToFontBitmap(Text, font: String): TMufasaBitmap;
|
||||
function TextToMask(Text, font: String): TMask;
|
||||
|
||||
|
||||
{$IFDEF OCRDEBUG}
|
||||
@ -766,5 +770,41 @@ begin
|
||||
result := bmp;
|
||||
end;
|
||||
|
||||
function TMOCR.TextToMask(Text, font: String): TMask;
|
||||
var
|
||||
TPA: TPointArray;
|
||||
w,h: integer;
|
||||
i,x,y : integer;
|
||||
dx,dy : integer;
|
||||
c : integer;
|
||||
bmp: TMufasaBitmap;
|
||||
Pixels : array of array of boolean; //White = true
|
||||
begin
|
||||
TPA := TextToFontTPA(text, font, w, h);
|
||||
Result.w := w;
|
||||
Result.h := h;
|
||||
Result.WhiteHi:= High(TPA);//High(WhitePixels)
|
||||
Result.BlackHi:= w*h - Length(TPA) - 1;//High(BlackPixels) = Length(blackPixels) - 1 = (TotalLength - LenWhitePixels) - 1
|
||||
SetLength(Pixels,w,h);
|
||||
SetLength(result.White,Result.WhiteHi + 1);
|
||||
SetLength(result.Black,Result.BlackHi + 1);
|
||||
for i := Result.WhiteHi downto 0 do
|
||||
begin
|
||||
Result.White[i] := TPA[i];
|
||||
Pixels[TPA[i].x][TPA[i].y] := true;
|
||||
end;
|
||||
c := 0;
|
||||
dx := w-1;
|
||||
dy := h-1;
|
||||
for y := 0 to dY do
|
||||
for x := 0 to dX do
|
||||
if not Pixels[x][y] then
|
||||
begin
|
||||
result.Black[c].x :=x;
|
||||
result.black[c].y := y;
|
||||
inc(c);
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user