2010-01-25 08:59:44 -05:00
|
|
|
{
|
|
|
|
This file is part of the Mufasa Macro Library (MML)
|
|
|
|
Copyright (c) 2009 by Raymond van Venetië and Merlijn Wajer
|
|
|
|
|
|
|
|
MML is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
MML is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with MML. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
See the file COPYING, included in this distribution,
|
|
|
|
for details about the copyright.
|
|
|
|
|
|
|
|
Bitmap.inc for the Mufasa Macro Library
|
|
|
|
}
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CreateBitmapString(bmp : integer) : string; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MBitmaps[bmp].ToString;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_GetMufasaBitmap(bmp : integer): TMufasaBitmap; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MBitmaps[bmp];
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CreateBitmap(w,h : integer):integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
result := CurrThread.Client.MBitmaps.CreateBMP(w,h);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FreeBitmap(Number : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps.FreeBMP(Number);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_SaveBitmap(Bmp : integer; path : string); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].SaveToFile(Path);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_BitmapFromString(Width,height : integer; Data : string) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps.CreateBMPFromString(Width,Height,Data);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_LoadBitmap(Path : String) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps.CreateBMPFromFile(Path);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_SetBitmapSize(Bmp,NewW,NewH : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
if (NewW>=0) and (NewH >=0) then
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].SetSize(NewW,NewH)
|
|
|
|
else
|
|
|
|
raise exception.createfmt('Wrong Width or Height in SetBitmapSize: (%d,%d)',[NewW,NewH]);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_StretchBitmapResize(Bmp,NewW,NewH : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
if (NewW>=0) and (NewH >=0) then
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].StretchResize(NewW,NewH)
|
|
|
|
else
|
|
|
|
raise exception.createfmt('Wrong Width or Height in ScretchResize: (%d,%d)',[NewW,NewH]);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
procedure ps_GetBitmapSize(Bmp : integer; var BmpW,BmpH : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
With CurrThread.Client.MBitmaps[bmp] do
|
|
|
|
begin;
|
|
|
|
BmpW := width;
|
|
|
|
BmpH := Height;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_SetBitmapName(Bmp : integer; name : string); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
2010-04-03 09:10:13 -04:00
|
|
|
CurrThread.Client.MBitmaps[Bmp].Name:= name;
|
2010-01-25 08:59:44 -05:00
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CreateMirroredBitmap(Bmp : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp, MirrorWidth);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CreateMirroredBitmapEx(Bmp : integer; MirrorStyle : TBmpMirrorStyle) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps.CreateMirroredBitmap(Bmp,MirrorStyle);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_FastGetPixel(bmp,x,y : integer) : LongWord; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps[Bmp].FastGetPixel(x,y);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_FastGetPixels(bmp : integer; TPA : TPointArray) : TIntegerArray; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MBitmaps[Bmp].FastGetPixels(TPA);
|
|
|
|
end;
|
|
|
|
|
2010-05-01 09:00:23 -04:00
|
|
|
function ps_GetBitmapAreaColors(bmp,xs, ys, xe, ye: Integer): T2DIntArray;extdecl;
|
|
|
|
begin
|
|
|
|
result := CurrThread.Client.MBitmaps[bmp].GetAreaColors(xs,ys,xe,ye);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FastSetPixel(Bmp,x,y : integer; Color : TColor); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bmp].FastSetPixel(x,y,color);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FastSetPixels(Bmp : integer; TPA : TPointArray; Colors : TIntegerArray); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].FastSetPixels(TPA,Colors);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_DrawTPABitmap(bitmap : integer; TPA : TPointArray; Color : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[Bitmap].DrawTPA(TPA,Color);
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_DrawATPABitmap(bitmap : integer; ATPA : T2DPointArray); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bitmap].DrawATPA(ATPA);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_DrawATPABitmapEx(bitmap : integer; ATPA : T2DPointArray; Colors : TIntegerArray); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bitmap].DrawATPA(ATPA,Colors);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FastDrawClear(bmp : integer; Color : TColor); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
CurrThread.Client.MBitmaps[bmp].FastDrawClear(Color);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_DrawBitmap(Bmp: Integer; Dest: TCanvas; x, y: Integer);extdecl;
|
2010-02-25 18:59:51 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bmp].DrawToCanvas(x,y,dest);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FastDrawTransparent(x, y: Integer; SourceBitmap, TargetBitmap: Integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
CurrThread.Client.MBitmaps[SourceBitmap].FastDrawTransparent(x,y,CurrThread.Client.MBitmaps[TargetBitmap]);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_SetTransparentColor(Bmp : integer; Color : TColor); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].SetTransparentColor(Color);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_GetTransparentColor(Bmp : integer) : TColor; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
Result := CurrThread.Client.MBitmaps[bmp].GetTransparentColor;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_FastReplaceColor(bmp: Integer; OldColor, NewColor: TColor); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[Bmp].FastReplaceColor(OldColor,NewColor);
|
|
|
|
end;
|
|
|
|
|
2010-01-28 18:34:03 -05:00
|
|
|
procedure ps_CopyClientToBitmap(bmp, xs, ys, xe, ye: Integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps.GetBMP(bmp).CopyClientToBitmap(CurrThread.Client.IOManager, True, xs, ys, xe, ye);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_BitmapFromClient(const xs, ys, xe, ye: Integer): Integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MBitmaps.CreateBMP(0,0);
|
|
|
|
CurrThread.Client.MBitmaps[result].CopyClientToBitmap(CurrThread.Client.IOManager,True,xs,ys,xe,ye);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindBitmap(Bitmap: integer; var x, y: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmap( MBitmaps[bitmap],x,y);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindBitmapIn(bitmap: integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmapIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindBitmapToleranceIn(bitmap: integer; var x, y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmapToleranceIn( MBitmaps[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_FindBitmapSpiral(bitmap: Integer; var x, y: Integer; xs, ys, xe, ye: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmapSpiral(Mbitmaps[bitmap],x,y,xs,ys,xe,ye);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindBitmapsSpiralTolerance(bitmap: integer; x, y: Integer; var Points : TPointArray; xs, ys, xe, ye,tolerance: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmapsSpiralTolerance(MBitmaps[bitmap],x,y,points,xs,ys,xe,ye,tolerance);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_FindBitmapSpiralTolerance(bitmap: integer; var x, y: Integer; xs, ys, xe, ye,tolerance : integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindBitmapSpiralTolerance(MBitmaps[bitmap],x,y,xs,ys,xe,ye,tolerance);
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_RotateBitmap(bitmap: Integer; angle: Extended): Integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin;
|
|
|
|
Result := CreateBMP(0,0);
|
|
|
|
Bmp[Bitmap].RotateBitmap(angle,Bmp[result]);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_Desaturate(Bitmap : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin;
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[Bitmap].Desaturate(Bmp[result]);
|
|
|
|
end;
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
procedure ps_InvertBitmap(Bitmap : integer); extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
CurrThread.Client.MBitmaps[Bitmap].Invert;
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CopyBitmap(Bitmap : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := Currthread.Client.MBitmaps.CopyBMP(bitmap);
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_GreyScaleBitmap(Bitmap : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin;
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[Bitmap].GreyScale(Bmp[result]);
|
|
|
|
end;
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_BrightnessBitmap(Bitmap,br : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin;
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[Bitmap].Brightness(Bmp[result],br);
|
|
|
|
end;
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_ContrastBitmap(bitmap : integer; co : extended) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin;
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[Bitmap].Contrast(Bmp[result],co);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_PosterizeBitmap(Bitmap : integer; po : integer) : integer; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[bitmap].Posterize(Bmp[result],po);
|
|
|
|
end;
|
|
|
|
end;
|
2010-04-07 17:04:25 -04:00
|
|
|
function ps_CreateMaskFromBitmap(Bitmap : integer) : TMask; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MBitmaps[Bitmap].CreateTMask;
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindMaskTolerance(const mask: TMask; var x, y: Integer; xs,ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MFinder.FindMaskTolerance(Mask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
|
|
|
end;
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindBitmapMaskTolerance(mask: Integer; var x, y: Integer; xs, ys, xe, ye: Integer; Tolerance, ContourTolerance: Integer): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
2010-03-22 10:58:30 -04:00
|
|
|
{$ifdef mDebug}
|
2010-03-08 15:31:06 -05:00
|
|
|
mDebugLn('Better be using FindMaskTolerance in combination with CreateMaskFromBitmap, more efficient.');
|
2010-03-22 10:58:30 -04:00
|
|
|
{$endif}
|
2010-01-25 08:59:44 -05:00
|
|
|
with CurrThread.Client do
|
|
|
|
result := MFinder.FindMaskTolerance(MBitmaps[mask].CreateTMask,x,y,xs,ys,xe,ye,tolerance,contourtolerance);
|
|
|
|
end;
|
|
|
|
|
2010-04-18 11:14:19 -04:00
|
|
|
function ps_FindDeformedBitmapToleranceIn(bitmap: integer; var x,
|
2010-01-25 08:59:44 -05:00
|
|
|
y: Integer; xs, ys, xe, ye: Integer; tolerance: Integer; Range: Integer;
|
2010-04-18 11:14:19 -04:00
|
|
|
AllowPartialAccuracy: Boolean; var accuracy: Extended): Boolean; extdecl;
|
2010-01-25 08:59:44 -05:00
|
|
|
begin;
|
|
|
|
result := CurrThread.Client.MFinder.FindDeformedBitmapToleranceIn(CurrThread.Client.MBitmaps[Bitmap],x,y,xs,ys,xe,ye,tolerance,range,AllowPartialAccuracy,accuracy);
|
|
|
|
end;
|
2010-04-13 14:10:30 -04:00
|
|
|
|
|
|
|
procedure ps_RectangleBitmap(bitmap : integer; const box : TBox; Color : TColor); extdecl;
|
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bitmap].Rectangle(box,Color);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure ps_FloodFillBitmap(bitmap : integer; const StartPoint : TPoint; const SearchCol,ReplaceCol : TColor); extdecl;
|
|
|
|
begin
|
|
|
|
CurrThread.Client.MBitmaps[bitmap].FloodFill(startPoint,searchcol,replacecol);
|
|
|
|
end;
|
2010-05-01 09:00:23 -04:00
|
|
|
|
2011-02-06 13:54:29 -05:00
|
|
|
function ps_ConvoluteBitmap(bitmap : integer; matrix : T2DExtendedArray) : integer; extdecl;
|
|
|
|
begin
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
begin
|
|
|
|
result := CreateBMP(0,0);
|
|
|
|
Bmp[bitmap].Convolute(Bmp[Result],matrix);
|
|
|
|
end;
|
|
|
|
end;
|
2010-05-01 09:00:23 -04:00
|
|
|
function ps_CalculatePixelShift(Bmp1,Bmp2 : Integer; CompareBox : TBox) : integer;extdecl;
|
|
|
|
begin
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
result := CalculatePixelShift(GetBMP(bmp1),GetBMP(bmp2),comparebox);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function ps_CalculatePixelTolerance(Bmp1,Bmp2 : Integer; CompareBox : TBox; CTS : integer) : extended;extdecl;
|
|
|
|
begin
|
|
|
|
with CurrThread.Client.MBitmaps do
|
|
|
|
result := CalculatePixelTolerance(GetBMP(bmp1),GetBMP(bmp2),comparebox,cts);
|
|
|
|
end;
|