1
0
mirror of https://github.com/moparisthebest/Simba synced 2025-03-06 04:09:40 -05:00

Mem leak fix

This commit is contained in:
Raymond 2010-04-18 17:14:19 +02:00
parent 1a8e3977b7
commit a7eccb53d2
14 changed files with 156 additions and 101 deletions

View File

@ -2045,7 +2045,7 @@ begin
Self.OnScriptStart:= @ScriptStartEvent;
FillThread := TProcThread.Create(true);
FillThread := TProcThread.Create;
FillThread.FreeOnTerminate:= True;
FillThread.NormalProc:= @CCFillCore;
UpdateTimer.OnTimer:= @UpdateTimerCheck;
@ -2359,15 +2359,14 @@ function TForm1.GetSimbaNews: String;
var
t: TDownloadThread;
begin
t := TDownloadThread.Create;
t.InputURL:=LoadSettingDef('Settings/News/URL', 'http://simba.villavu.com/bin/news');
t := TDownloadThread.Create(LoadSettingDef('Settings/News/URL', 'http://simba.villavu.com/bin/news'),
@Result);
t.Resume;
while not t.done do
begin
Application.ProcessMessages;
Sleep(50);
end;
Exit(t.ResultStr);
end;
procedure TForm1.SetExtPath(const AValue: string);
@ -2634,6 +2633,7 @@ var
FontDownload : TDownloadThread;
Stream : TStringStream;
UnTarrer : TUntarThread;
Fonts : string;
Decompress : TDecompressThread;
begin
if UpdatingFonts then
@ -2644,12 +2644,13 @@ begin
if LatestVersion > CurrVersion then
begin;
formWriteln(format('New fonts available. Current version: %d. Latest version: %d',[CurrVersion,LatestVersion]));
FontDownload := TDownloadThread.Create(True);
FontDownload.InputURL:= LoadSettingDef('Settings/Fonts/UpdateLink',FontURL + 'Fonts.tar.bz2');
FontDownload := TDownloadThread.Create(LoadSettingDef('Settings/Fonts/UpdateLink',FontURL + 'Fonts.tar.bz2'),
@Fonts);
FontDownload.resume;
while FontDownload.Done = false do
Idler;
Stream := TStringStream.Create(FontDownload.ResultStr);
//Fontdownload is freed now
Stream := TStringStream.Create(Fonts);
try
Decompress := TDecompressThread.Create(Stream);
Decompress.Resume;
@ -2676,7 +2677,6 @@ begin
Decompress.free;
finally
Stream.Free;
FontDownload.Free;
end;
end;
UpdatingFonts := False;

View File

@ -15,11 +15,12 @@ type
{ TDownloadThread }
TDownloadThread = class(TThread)
public
ResultStr : string;
private
InputURL : string;
ResultStr : PString;
public
Done : boolean;
constructor Create;
constructor Create(const URL : string; const Output : PString);
procedure Execute; override;
end;
TSimbaUpdateForm = class(TForm)
@ -91,20 +92,22 @@ begin
end;
function TSimbaUpdateForm.GetLatestFontVersion: integer;
var
Vers : string;
begin
if FontVersionThread = nil then//Create thread (only if no-other one is already running)
begin
FontVersionThread := TDownloadThread.Create(true);
FontVersionThread.InputURL := SettingsForm.Settings.GetKeyValueDefLoad(
'Settings/Fonts/VersionLink',FontURL + 'Version',SimbaSettingsFile);
FontVersionThread := TDownloadThread.Create(SettingsForm.Settings.GetKeyValueDefLoad(
'Settings/Fonts/VersionLink',FontURL + 'Version',SimbaSettingsFile),
@Vers);
FontVersionThread.Resume;
while FontVersionThread.Done = false do//Wait till thread is done
begin
Application.ProcessMessages;
Sleep(25);
end;
FFontVersion := StrToIntDef(Trim(FontVersionThread.ResultStr), -1);//Read output
FreeAndNil(FontVersionThread);//Free the thread
FFontVersion := StrToIntDef(Trim(Vers), -1);//Read output
FontVersionThread := nil; //It's already freed
end else
begin
//Another thread is already running, lets wait for it! (When it's nil, it means that the result is written!)
@ -119,21 +122,22 @@ begin
end;
function TSimbaUpdateForm.GetLatestSimbaVersion: Integer;
var
Vers : string;
begin
if SimbaVersionThread = nil then//Create thread (only if no-other one is already running)
begin
SimbaVersionThread := TDownloadThread.Create(true);
SimbaVersionThread.InputURL := SettingsForm.Settings.GetKeyValueDefLoad(
'Settings/Updater/RemoteVersionLink',SimbaURL + 'Version',SimbaSettingsFile);
SimbaVersionThread := TDownloadThread.Create(SettingsForm.Settings.GetKeyValueDefLoad(
'Settings/Updater/RemoteVersionLink',SimbaURL + 'Version'
,SimbaSettingsFile),@Vers);
SimbaVersionThread.Resume;
while SimbaVersionThread.Done = false do//Wait till thread is done
begin
Application.ProcessMessages;
Sleep(25);
end;
FSimbaVersion := StrToIntDef(Trim(SimbaVersionThread.ResultStr), -1);//Read output
FreeAndNil(SimbaVersionThread);//Free the thread
FSimbaVersion := StrToIntDef(Trim(Vers), -1);//Read output
SimbaVersionThread := nil;//It's automatically freed
end else
begin
//Another thread is already running, lets wait for it! (When it's nil, it means that the result is written!)
@ -264,17 +268,19 @@ begin
FUpdating:= false;
end;
constructor TDownloadThread.Create;
constructor TDownloadThread.Create(const url : String; const Output : PString);
begin
inherited Create(true);
FreeOnTerminate:= True;
InputURL:= url;
ResultStr:= Output;
end;
{ TDownloadThread }
procedure TDownloadThread.Execute;
begin
ResultStr:= GetPage(InputURL);
ResultStr^:= GetPage(InputURL);
done := true;
end;

View File

@ -71,7 +71,7 @@ begin;
raise exception.createfmt('Wrong Width or Height in ScretchResize: (%d,%d)',[NewW,NewH]);
end;
procedure ps_GetBitmapSize(Bmp : integer; out BmpW,BmpH : integer); extdecl;
procedure ps_GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer); extdecl;
begin;
With CurrThread.Client.MBitmaps[bmp] do
begin;
@ -170,19 +170,19 @@ begin;
CurrThread.Client.MBitmaps[result].CopyClientToBitmap(CurrThread.Client.IOManager,True,xs,ys,xe,ye);
end;
function ps_FindBitmap(Bitmap: integer; out x, y: Integer): Boolean; extdecl;
function ps_FindBitmap(Bitmap: integer; var x, y: Integer): Boolean; extdecl;
begin;
with CurrThread.Client do
result := MFinder.FindBitmap( MBitmaps[bitmap],x,y);
end;
function ps_FindBitmapIn(bitmap: integer; out x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
function ps_FindBitmapIn(bitmap: integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
begin;
with CurrThread.Client do
result := MFinder.FindBitmapIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye);
end;
function ps_FindBitmapToleranceIn(bitmap: integer; out x, y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer): Boolean; extdecl;
function ps_FindBitmapToleranceIn(bitmap: integer; var x, y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer): Boolean; extdecl;
begin;
with CurrThread.Client do
result := MFinder.FindBitmapToleranceIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye,tolerance);
@ -195,7 +195,7 @@ begin;
result := MFinder.FindBitmapSpiral(Mbitmaps[bitmap],x,y,xs,ys,xe,ye);
end;
function ps_FindBitmapsSpiralTolerance(bitmap: integer; x, y: Integer; out Points : TPointArray; xs, ys, xe, ye,tolerance: Integer): Boolean; extdecl;
function ps_FindBitmapsSpiralTolerance(bitmap: integer; x, y: Integer; var Points : TPointArray; xs, ys, xe, ye,tolerance: Integer): Boolean; extdecl;
begin;
with CurrThread.Client do
result := MFinder.FindBitmapsSpiralTolerance(MBitmaps[bitmap],x,y,points,xs,ys,xe,ye,tolerance);
@ -270,11 +270,11 @@ begin;
result := CurrThread.Client.MBitmaps[Bitmap].CreateTMask;
end;
function ps_FindMaskTolerance(const mask: TMask; out x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
function ps_FindMaskTolerance(const mask: TMask; var x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
begin;
result := CurrThread.Client.MFinder.FindMaskTolerance(Mask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
end;
function ps_FindBitmapMaskTolerance(mask: Integer; out x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
function ps_FindBitmapMaskTolerance(mask: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
begin;
{$ifdef mDebug}
mDebugLn('Better be using FindMaskTolerance in combination with CreateMaskFromBitmap, more efficient.');
@ -283,9 +283,9 @@ begin;
result := MFinder.FindMaskTolerance(MBitmaps[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
end;
function ps_FindDeformedBitmapToleranceIn(bitmap: integer; out x,
function ps_FindDeformedBitmapToleranceIn(bitmap: integer; var x,
y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer; Range: Integer;
AllowPartialAccuracy: Boolean; out accuracy: Extended): Boolean; extdecl;
AllowPartialAccuracy: Boolean; var accuracy: Extended): Boolean; extdecl;
begin;
result := CurrThread.Client.MFinder.FindDeformedBitmapToleranceIn(CurrThread.Client.MBitmaps[Bitmap],x,y,xs,ys,xe,ye,tolerance,range,AllowPartialAccuracy,accuracy);
end;

View File

@ -36,21 +36,21 @@ begin
result := CurrThread.Client.MFinder.GetColors(coords);
end;
function ps_findcolor(out x, y: integer; color, x1, y1, x2, y2: integer): boolean; extdecl;
function ps_findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean; extdecl;
begin
Result := CurrThread.Client.MFinder.FindColor(x, y, color, x1, y1, x2, y2);
end;
function ps_findcolortoleranceOptimised(out x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; extdecl;
function ps_findcolortoleranceOptimised(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; extdecl;
begin
Result := CurrThread.Client.MFinder.FindColorToleranceOptimised(x, y, color, x1, y1, x2, y2, tol);
end;
function ps_findcolortolerance(out x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; extdecl;
function ps_findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; extdecl;
begin
Result := CurrThread.Client.MFinder.FindColorTolerance(x, y, color, x1, y1, x2, y2, tol);
end;
function ps_FindColors(out TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; extdecl;
function ps_FindColors(var TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; extdecl;
begin
Result := CurrThread.Client.MFinder.FindColors(TPA, color, x1, y1, x2, y2);
end;
@ -70,7 +70,7 @@ begin
CurrThread.Client.MFinder.SetToleranceSpeed2Modifiers(nHue, nSat);
end;
procedure ps_GetToleranceSpeed2Modifiers(out hMod, sMod: Extended); extdecl;
procedure ps_GetToleranceSpeed2Modifiers(var hMod, sMod: Extended); extdecl;
begin
CurrThread.Client.MFinder.GetToleranceSpeed2Modifiers(hMod, sMod);
end;
@ -89,11 +89,11 @@ begin;
result := CurrThread.Client.MFinder.CountColorTolerance(color,xs,ys,xe,ye,tolerance);
end;
function ps_FindColorsToleranceOptimised(out Points: TPointArray; Color, xs, ys, xe, ye, Tolerance: Integer): Boolean; extdecl;
function ps_FindColorsToleranceOptimised(var Points: TPointArray; Color, xs, ys, xe, ye, Tolerance: Integer): Boolean; extdecl;
begin;
result := CurrThread.Client.MFinder.FindColorsToleranceOptimised(points,color,xs,ys,xe,ye,tolerance);
end;
function ps_FindColorsTolerance(out Points: TPointArray; Color, xs, ys, xe, ye, Tolerance: Integer): Boolean; extdecl;
function ps_FindColorsTolerance(var Points: TPointArray; Color, xs, ys, xe, ye, Tolerance: Integer): Boolean; extdecl;
begin;
result := CurrThread.Client.MFinder.FindColorsTolerance(points,color,xs,ys,xe,ye,tolerance);
end;
@ -108,7 +108,7 @@ begin
result := CurrThread.Client.MFinder.FindColorSpiralTolerance(x,y,color,xs,ys,xe,ye,tol);
end;
function ps_FindColorsSpiralTolerance(x, y: Integer; out Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean; extdecl;
function ps_FindColorsSpiralTolerance(x, y: Integer; var Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean; extdecl;
begin;
result := CurrThread.Client.MFinder.FindColorsSpiralTolerance(x,y,Points,color,xs,ys,xe,ye,tolerance);
end;

View File

@ -1,9 +1,14 @@
procedure ps_ColorToRGB(Color: integer; var r, g, b: Byte);extdecl;
procedure ps_ColorToRGB(Color: integer; var r, g, b: Integer);extdecl;
var
RR,GG,BB : byte;
begin
colour_conv.ColorToRGB(color,r,g,b);
colour_conv.ColorToRGB(color,rr,gg,bb);
r := rr;
g := gg;
b := bb;
end;
function ps_RGBtoColor(r, g, b: Byte): TColor;extdecl;
function ps_RGBtoColor(r, g, b: Integer): TColor;extdecl;
begin
result := RGBtoColor(r,g,b);
end;
@ -28,21 +33,31 @@ begin
result := XYZToColor(x,y,z);
end;
procedure ps_RGBToHSL(R, G, B: Byte; var h, s, l: Extended);extdecl;
procedure ps_RGBToHSL(R, G, B: Integer; var h, s, l: Extended);extdecl;
begin
RGBToHSL(r,g,b,h,s,l);
end;
procedure ps_HSLtoRGB(H, S, L: extended; var R, G ,B: Byte);extdecl;
procedure ps_HSLtoRGB(H, S, L: extended; var R, G ,B: Integer);extdecl;
var
RR,GG,BB : byte;
begin
HSLtoRGB(h,s,l,r,g,b);
HSLtoRGB(h,s,l,rr,gg,bb);
r := rr;
g := gg;
b := bb;
end;
procedure ps_RGBToXYZ(R, G, B: Byte;var x, y ,z: Extended);extdecl;
procedure ps_RGBToXYZ(R, G, B: Integer;var x, y ,z: Extended);extdecl;
begin
RGBToXYZ(r,g,b,x,y,z);
end;
procedure ps_XYZToRGB(X, Y, Z: Extended; var R, G, B: Byte);extdecl;
begin
XYZToRGB(x,y,z,r,g,b);
procedure ps_XYZToRGB(X, Y, Z: Extended; var R, G, B: Integer);extdecl;
var
RR,GG,BB : byte;
begin;
XYZToRGB(x,y,z,rr,gg,bb);
r := rr;
g := gg;
b := bb;
end;

View File

@ -21,42 +21,42 @@
DTM.inc for the Mufasa Macro Library
}
function ps_FindDTM(DTM: Integer; out x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
function ps_FindDTM(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTM(MDTM.GetDTM(DTM),x,y,xs,ys,xe,ye);
end;
function ps_FindDTMs(DTM: Integer; out p: TPointArray; xs, ys, xe, ye: Integer): Boolean; extdecl;
function ps_FindDTMs(DTM: Integer; var p: TPointArray; xs, ys, xe, ye: Integer): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTMs(MDTM.GetDTM(DTM), p, xs, ys, xe, ye);
end;
function ps_FindDTMRotatedAlternating(DTM: Integer; out x, y: Integer; xs, ys, xe, ye:
function ps_FindDTMRotatedAlternating(DTM: Integer; var x, y: Integer; xs, ys, xe, ye:
Integer; sAngle, eAngle, aStep: Extended;
out aFound: Extended): Boolean; extdecl;
var aFound: Extended): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTMRotated(MDTM.GetDTM(DTM), x,y, xs, ys, xe, ye, sAngle, eAngle, aStep, aFound,true);
end;
function ps_FindDTMRotatedSE(DTM: Integer; out x, y: Integer; xs, ys, xe, ye:
function ps_FindDTMRotatedSE(DTM: Integer; var x, y: Integer; xs, ys, xe, ye:
Integer; sAngle, eAngle, aStep: Extended;
out aFound: Extended): Boolean; extdecl;
var aFound: Extended): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTMRotated(MDTM.GetDTM(DTM), x, y, xs, ys, xe, ye, sAngle, eAngle, aStep, aFound,false);
end;
function ps_FindDTMsRotatedAlternating(DTM: Integer; out Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
function ps_FindDTMsRotatedAlternating(DTM: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTMsRotated(MDTM.GetDTM(DTM), Points, xs, ys, xe, ye,
sAngle, eAngle, aStep, aFound, true);
end;
function ps_FindDTMsRotatedSE(DTM: Integer; out Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
function ps_FindDTMsRotatedSE(DTM: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: T2DExtendedArray): Boolean; extdecl;
begin
with CurrThread.Client do
result := MFinder.FindDTMsRotated(MDTM.GetDTM(DTM), Points, xs, ys, xe, ye,

View File

@ -23,7 +23,7 @@
type
TStringArray = array of string;
function ext_UnTar(const Input : string; out Content : TStringArray) : boolean;
function ext_UnTar(const Input : string; var Content : TStringArray) : boolean;
var
Stream : TStringStream;
begin
@ -58,7 +58,7 @@ begin
stream.free;
end;
end;
function ext_DecompressBZip2(const input: string;out output : string; const BlockSize: Cardinal): boolean;
function ext_DecompressBZip2(const input: string;var output : string; const BlockSize: Cardinal): boolean;
var
Stream : TStringStream;
Decompress : TDecompressThread;
@ -95,15 +95,13 @@ var
begin
result := '';
try
t := TDownloadThread.Create(true);
t.InputURL:=url;
t := TDownloadThread.Create(url,@result);
t.Resume;
while not t.done do
begin
Application.ProcessMessages;
Sleep(25);
end;
Exit(t.ResultStr);
except
on e : exception do
mDebugLn('Exception in GetPage in Extensions: ' + e.message);

View File

@ -134,7 +134,7 @@ begin;
x := x mod (1000 * 60);
s := x div (1000);
end;
procedure ps_DecodeDate ( const SourceDate : TDateTime; out Year, Month, Day : Word ); extdecl;
procedure ps_DecodeDate ( const SourceDate : TDateTime; var Year, Month, Day : Word ); extdecl;
begin
decodedate(sourcedate,year,month,day);
end;

View File

@ -278,69 +278,69 @@ begin
result := AverageExtended(te);
end;
procedure ps_SplitTPAExWrap(arr: TPointArray; w, h: Integer; out res : T2DPointArray);extdecl;
procedure ps_SplitTPAExWrap(arr: TPointArray; w, h: Integer; var res : T2DPointArray);extdecl;
begin
res := SplitTPAEx(arr,w,h);
end;
procedure ps_SplitTPAWrap(arr: TPointArray; Dist: Integer; out res: T2DPointArray);extdecl;
procedure ps_SplitTPAWrap(arr: TPointArray; Dist: Integer; var res: T2DPointArray);extdecl;
begin
res := SplitTPA(arr,dist);
end;
procedure ps_FindGapsTPAWrap(TPA: TPointArray; MinPixels: Integer; out Res : T2DPointArray); extdecl;
procedure ps_FindGapsTPAWrap(TPA: TPointArray; MinPixels: Integer; var Res : T2DPointArray); extdecl;
begin
Res := FindGapsTPA(TPA,MinPixels);
end;
procedure ps_RemoveDistTPointArrayWrap(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean; out Res : TPointArray);extdecl;
procedure ps_RemoveDistTPointArrayWrap(x, y, dist: Integer; ThePoints: TPointArray; RemoveHigher: Boolean; var Res : TPointArray);extdecl;
begin
Res := RemoveDistTPointArray(x,y,dist,thepoints,removehigher);
end;
procedure ps_CombineTPAWrap(Ar1, Ar2: TPointArray; out Res : TPointArray);extdecl;
procedure ps_CombineTPAWrap(Ar1, Ar2: TPointArray; var Res : TPointArray);extdecl;
begin
Res := CombineTPA(Ar1,Ar2);
end;
procedure ps_ReArrangeandShortenArrayExWrap(a: TPointArray; w, h: Integer; out Res : TPointArray);extdecl;
procedure ps_ReArrangeandShortenArrayExWrap(a: TPointArray; w, h: Integer; var Res : TPointArray);extdecl;
begin
Res := ReArrangeandShortenArrayEx(a,w,h);
end;
procedure ps_ReArrangeandShortenArrayWrap(a: TPointArray; Dist: Integer; out Res : TPointArray);extdecl;
procedure ps_ReArrangeandShortenArrayWrap(a: TPointArray; Dist: Integer; var Res : TPointArray);extdecl;
begin
Res := ReArrangeandShortenArray(a,dist);
end;
procedure ps_TPAtoATPAExWrap(TPA: TPointArray; w, h: Integer; out Res : T2DPointArray);extdecl;
procedure ps_TPAtoATPAExWrap(TPA: TPointArray; w, h: Integer; var Res : T2DPointArray);extdecl;
begin
Res := TPAtoATPAEx(TPA,w,h);
end;
procedure ps_TPAtoATPAWrap(TPA: TPointArray; Dist: Integer; out Res : T2DPointArray);extdecl;
procedure ps_TPAtoATPAWrap(TPA: TPointArray; Dist: Integer; var Res : T2DPointArray);extdecl;
begin
Res := TPAtoATPA(TPA,Dist);
end;
procedure ps_CombineIntArrayWrap(Ar1, Ar2: TIntegerArray; out Res : TIntegerArray);extdecl;
procedure ps_CombineIntArrayWrap(Ar1, Ar2: TIntegerArray; var Res : TIntegerArray);extdecl;
begin
Res := CombineIntArray(Ar1,Ar2);
end;
procedure ps_MergeATPAWrap(ATPA : T2DPointArray; out Res: TPointArray); extdecl;
procedure ps_MergeATPAWrap(ATPA : T2DPointArray; var Res: TPointArray); extdecl;
begin
Res := MergeATPA(ATPA);
end;
procedure ps_TPAFromBoxWrap(const Box : TBox; out Res : TPointArray);extdecl;
procedure ps_TPAFromBoxWrap(const Box : TBox; var Res : TPointArray);extdecl;
begin
Res := TPAFromBox(Box);
end;
procedure ps_RotatePointsWrap(Const P: TPointArray; A, cx, cy: Extended; out Res : TPointArray);extdecl;
procedure ps_RotatePointsWrap(Const P: TPointArray; A, cx, cy: Extended; var Res : TPointArray);extdecl;
begin
Res := RotatePoints(P,a,cx,cy);
end;
procedure ps_FindTPAEdgesWrap(p: TPointArray; out Res : TPointArray);extdecl;
procedure ps_FindTPAEdgesWrap(p: TPointArray; var Res : TPointArray);extdecl;
begin
Res := FindTPAEdges(p);
end;
procedure ps_ClearTPAFromTPAWrap(arP, ClearPoints: TPointArray; out Res : TPointArray);extdecl;
procedure ps_ClearTPAFromTPAWrap(arP, ClearPoints: TPointArray; var Res : TPointArray);extdecl;
begin
Res := ClearTPAFromTPA(arP, clearpoints);
end;
procedure ps_ReturnPointsNotInTPAWrap(Const TotalTPA: TPointArray; const Box: TBox; out Res : TPointArray);extdecl;
procedure ps_ReturnPointsNotInTPAWrap(Const TotalTPA: TPointArray; const Box: TBox; var Res : TPointArray);extdecl;
begin
Res := ReturnPointsNotInTPA(TotalTPA,box);
end;

View File

@ -76,7 +76,7 @@ begin
CurrThread.Client.IOManager.FreeTarget(idx);
end;
procedure ps_GetClientDimensions(out w, h: integer); extdecl;
procedure ps_GetClientDimensions(var w, h: integer); extdecl;
begin
CurrThread.Client.IOManager.GetDimensions(w, h);
end;

View File

@ -32,8 +32,8 @@ AddFunction(@ps_DTMFromString, 'function DTMFromString(const DTMString: String):
AddFunction(@ps_FreeDTM, 'procedure FreeDTM(DTM: Integer);');
AddFunction(@ps_FindDTM, 'function FindDTM(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean;');
AddFunction(@ps_FindDTMs, 'function FindDTMs(DTM: Integer; var p: TPointArray; xs, ys, xe, ye: Integer): Boolean;');
AddFunction(@ps_FindDTMRotatedSE, 'function FindDTMRotatedSE(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;');
AddFunction(@ps_FindDTMRotatedAlternating, 'function FindDTMRotatedAlternating(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; out aFound: Extended): Boolean;');
AddFunction(@ps_FindDTMRotatedSE, 'function FindDTMRotatedSE(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; var aFound: Extended): Boolean;');
AddFunction(@ps_FindDTMRotatedAlternating, 'function FindDTMRotatedAlternating(DTM: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; var aFound: Extended): Boolean;');
AddFunction(@ps_FindDTMsRotatedSE, 'function FindDTMsRotatedSE(DTM: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
AddFunction(@ps_FindDTMsRotatedAlternating, 'function FindDTMsRotatedAlternating(DTM: Integer; var Points: TPointArray; xs, ys, xe, ye: Integer; sAngle, eAngle, aStep: Extended; var aFound: T2DExtendedArray) : Boolean;');
AddFunction(@ps_addDTM, 'function AddDTM(const d: TDTM): Integer;');
@ -180,16 +180,16 @@ AddFunction(@ps_GetRawHeaders,'function GetRawHeaders(Client: Integer): string;'
{ Color Conversions and Speed }
SetCurrSection('Color Convert');
AddFunction(@ps_ColorToRGB, 'procedure ColorToRGB(Color: integer; var r, g, b: Byte);');
AddFunction(@ps_RGBToColor, 'function RGBtoColor(r, g, b: Byte): TColor;');
AddFunction(@ps_ColorToRGB, 'procedure ColorToRGB(Color: integer; var r, g, b: Integer);');
AddFunction(@ps_RGBToColor, 'function RGBtoColor(r, g, b: Integer): TColor;');
AddFunction(@ps_ColorToHSL, 'procedure ColorToHSL(Color: Integer; var h, s, l: Extended);');
AddFunction(@ps_HSLToColor, 'function HSLToColor(H, S, L: Extended): TColor;');
AddFunction(@ps_ColorToXYZ, 'procedure ColorToXYZ(Color: Integer; var x, y, z: Extended);');
AddFunction(@ps_XYZToColor, 'function XYZToColor(X, Y, Z: Extended): TColor;');
AddFunction(@ps_RGBToHSL, 'procedure RGBToHSL(R, G, B: Byte; var h, s, l: Extended);');
AddFunction(@ps_HSLToRGB, 'procedure HSLtoRGB(H, S, L: extended; var R, G ,B: Byte);');
AddFunction(@ps_RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Byte;var x, y ,z: Extended);');
AddFunction(@ps_XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; var R, G, B: Byte);');
AddFunction(@ps_RGBToHSL, 'procedure RGBToHSL(R, G, B: Integer; var h, s, l: Extended);');
AddFunction(@ps_HSLToRGB, 'procedure HSLtoRGB(H, S, L: extended; var R, G ,B: Integer);');
AddFunction(@ps_RGBToXYZ, 'procedure RGBToXYZ(R, G, B: Integer;var x, y ,z: Extended);');
AddFunction(@ps_XYZToRGB, 'procedure XYZToRGB(X, Y, Z: Extended; var R, G, B: Integer);');
{ Color Finding }
SetCurrSection('Color');

View File

@ -81,7 +81,8 @@ type
procedure Invert;overload;
procedure Posterize(TargetBitmap : TMufasaBitmap; Po : integer);overload;
procedure Posterize(Po : integer);overload;
function Copy: TMufasaBitmap;
function Copy: TMufasaBitmap;overload;
function Copy(const xs,ys,xe,ye : integer) : TMufasaBitmap; overload;
function ToTBitmap: TBitmap;
function ToString : string;
procedure LoadFromTBitmap(bmp: TBitmap);
@ -519,6 +520,18 @@ begin
Move(self.FData[0], Result.FData[0],self.w * self.h * SizeOf(TRGB32));
end;
function TMufasaBitmap.Copy(const xs, ys, xe, ye: integer): TMufasaBitmap;
var
i : integer;
begin
ValidatePoint(xs,ys);
ValidatePoint(xe,ye);
Result := TMufasaBitmap.Create;
Result.SetSize(xe-xs+1, ye-ys+1);
for i := ys to ye do
Move(self.FData[i * self.w + xs], Result.FData[i-ys],result.Width * SizeOf(TRGB32));
end;
function TMufasaBitmap.ToTBitmap: TBitmap;
var
@ -733,12 +746,15 @@ begin
StartPtr := Self.FData;
For y := 0 to Self.h - 1 do
For x := 0 to self.w - 1 do
begin
StartPtr^.A := 0;
if LongWord(StartPtr^) = LongWord(Search) then
begin;
L := L + 1;
Result[L].x := x;
Result[L].y := y;
end;
end;
SetLength(Result,L + 1);
end;
@ -809,9 +825,11 @@ begin
begin;
for loopy := 0 to MinH do
for loopx := 0 to MinW do
begin;
FData[loopy * w + loopx].A := 0;
if LongWord(FData[loopy * w + loopx]) <> LongWord(FTransparentColor) then
TargetBitmap.FData[(loopy + y) * TargetW + loopx + x] := FData[Loopy * w + loopx];
end;
end
else
for loopy := 0 to MinH do
@ -827,8 +845,11 @@ begin
OldCol := RGBToBGR(OldColor);
NewCol := RGBToBGR(NewColor);
for i := w*h-1 downto 0 do
begin
FData[i].a := 0;
if LongWord(FData[i]) = LongWord(OldCol) then
FData[i] := NewCol;
end;
end;
procedure TMufasaBitmap.CopyClientToBitmap(MWindow : TObject;Resize : boolean; xs, ys, xe, ye: Integer);
@ -1212,16 +1233,24 @@ end;
destructor TMBitmaps.Destroy;
var
I : integer;
WriteStr : string;
begin
WriteStr := '[';
for i := 0 to BmpsCurr do
if BmpArray[i] <> nil then
begin;
if BmpArray[i].Name = '' then
TClient(Client).Writeln(Format('BMP[%d] has not been freed in the script, freeing it now.',[i]))
WriteStr := WriteStr + inttostr(i) + ', '
else
TClient(Client).Writeln(Format('BMP[%s] has not been freed in the script, freeing it now.',[BmpArray[i].Name]));
WriteStr := WriteStr + bmpArray[i].Name + ', ';
FreeAndNil(BmpArray[i]);
end;
if WriteStr <> '[' then //Has unfreed bitmaps
begin
SetLength(WriteStr,length(WriteStr)-1);
WriteStr[Length(writeStr)] := ']';
TClient(Client).Writeln(Format('The following bitmaps were not freed: %s',[WriteStr]));
end;
SetLength(BmpArray,0);
SetLength(FreeSpots,0);
inherited Destroy;

View File

@ -73,11 +73,12 @@ end;
{$DEFINE DTM_DEBUG}
destructor TMDTM.Destroy;
var
i, j: integer;
b:boolean;
WriteStr : string;
begin
WriteStr := '[';
for i := 0 to high(DTMList) do
begin
b := false;
@ -90,12 +91,18 @@ begin
if not b then
begin;
if DTMList[i].n <> '' then
TClient(Client).Writeln(Format('DTM[%s] has not been freed in the script, freeing it now.',[DTMList[i].n]))
WriteStr := WriteStr + DTMList[i].n + ', '
else
TClient(Client).Writeln(Format('DTM[%d] has not been freed in the script, freeing it now.',[i]));
WriteStr := WriteStr + inttostr(i) + ', ';
FreeDTM(i);
end;
end;
if WriteStr <> '[' then //Has unfreed DTMs
begin
SetLength(WriteStr,length(WriteStr)-1);
WriteStr[Length(writeStr)] := ']';
TClient(Client).Writeln(Format('The following DTMs were not freed: %s',[WriteStr]));
end;
SetLength(DTMList, 0);
SetLength(FreeSpots, 0);

View File

@ -69,7 +69,7 @@ type
function FindColorTolerance(out x, y: Integer; Color, xs, ys, xe, ye, tol: Integer): Boolean;
function FindColorsTolerance(out Points: TPointArray; Color, xs, ys, xe, ye, Tol: Integer): Boolean;
function FindColorsSpiralTolerance(x, y: Integer; out Points: TPointArray; color, xs, ys, xe, ye: Integer; Tolerance: Integer) : boolean;
function FindColors(out TPA: TPointArray; Color, xs, ys, xe, ye: Integer): Boolean;
function FindColors(var TPA: TPointArray; Color, xs, ys, xe, ye: Integer): Boolean;
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
@ -1302,7 +1302,7 @@ begin
TClient(Client).IOManager.FreeReturnData;
end;
function TMFinder.FindColors(out TPA: TPointArray; Color, xs, ys, xe, ye: Integer): Boolean;
function TMFinder.FindColors(var TPA: TPointArray; Color, xs, ys, xe, ye: Integer): Boolean;
var
PtrData: TRetData;
Ptr: PRGB32;