From 68c49e0774623ec1e205d2e96c93a204a0d2e798 Mon Sep 17 00:00:00 2001 From: Raymond Date: Fri, 18 Sep 2009 20:08:15 +0000 Subject: [PATCH] Added GetColor git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@70 3f818213-9676-44b0-a9b4-5e4c4e03d09d --- Units/MMLAddon/PSInc/Wrappers/colour.inc | 53 +++++++++++++----------- Units/MMLAddon/PSInc/pscompile.inc | 1 + Units/MMLCore/window.pas | 15 +++++++ 3 files changed, 45 insertions(+), 24 deletions(-) diff --git a/Units/MMLAddon/PSInc/Wrappers/colour.inc b/Units/MMLAddon/PSInc/Wrappers/colour.inc index 5049d68..3b2c217 100644 --- a/Units/MMLAddon/PSInc/Wrappers/colour.inc +++ b/Units/MMLAddon/PSInc/Wrappers/colour.inc @@ -1,24 +1,29 @@ -function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean; -begin - Result := CurrThread.Client.MFinder.FindColor(x, y, color, x1, y1, x2, y2); -end; - -function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; -begin - Result := CurrThread.Client.MFinder.FindColorTolerance(x, y, color, x1, y1, x2, y2, tol); -end; - -function FindColors(var TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; -begin - Result := CurrThread.Client.MFinder.FindColors(TPA, color, x1, y1, x2, y2); -end; - -procedure SetColorToleranceSpeed(cts: Integer); -begin - CurrThread.Client.MFinder.SetToleranceSpeed(cts); -end; - -function SimilarColors(Col1,Col2,Tol : integer) : boolean; -begin; - Result := CurrThread.Client.MFinder.SimilarColors(Col1,Col2,Tol); -end; +function GetColor(x,y : integer) : TColor; +begin; + Result := CurrThread.Client.MWindow.GetColor(x,y); +end; + +function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean; +begin + Result := CurrThread.Client.MFinder.FindColor(x, y, color, x1, y1, x2, y2); +end; + +function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean; +begin + Result := CurrThread.Client.MFinder.FindColorTolerance(x, y, color, x1, y1, x2, y2, tol); +end; + +function FindColors(var TPA: TPointArray; Color, x1, y1, x2, y2: Integer): Boolean; +begin + Result := CurrThread.Client.MFinder.FindColors(TPA, color, x1, y1, x2, y2); +end; + +procedure SetColorToleranceSpeed(cts: Integer); +begin + CurrThread.Client.MFinder.SetToleranceSpeed(cts); +end; + +function SimilarColors(Col1,Col2,Tol : integer) : boolean; +begin; + Result := CurrThread.Client.MFinder.SimilarColors(Col1,Col2,Tol); +end; diff --git a/Units/MMLAddon/PSInc/pscompile.inc b/Units/MMLAddon/PSInc/pscompile.inc index 48aa2ea..d22762f 100644 --- a/Units/MMLAddon/PSInc/pscompile.inc +++ b/Units/MMLAddon/PSInc/pscompile.inc @@ -7,6 +7,7 @@ Sender.Comp.AddTypeS('TBmpMirrorStyle','(MirrorWidth,MirrorHeight,MirrorLine)'); Sender.AddFunction(@ThreadSafeCall,'function ThreadSafeCall(ProcName: string; var V: TVariantArray): Variant;'); Sender.AddFunction(@psWriteln,'procedure writeln(s : string);'); +Sender.AddFunction(@GetColor,'function GetColor(x, y: Integer): Integer;'); Sender.AddFunction(@FindColor, 'function findcolor(var x, y: integer; color, x1, y1, x2, y2: integer): boolean;'); Sender.AddFunction(@FindColorTolerance, 'function findcolortolerance(var x, y: integer; color, x1, y1, x2, y2, tol: integer): boolean;'); Sender.AddFunction(@FindColors, 'function findcolors(var TPA: TPointArray; color, x1, y1, x2, y2: integer): boolean;'); diff --git a/Units/MMLCore/window.pas b/Units/MMLCore/window.pas index c03e0ab..15119ac 100644 --- a/Units/MMLCore/window.pas +++ b/Units/MMLCore/window.pas @@ -20,6 +20,7 @@ type { TMWindow } TMWindow = class(TObject) + function GetColor(x,y : integer) : TColor; function ReturnData(xs, ys, width, height: Integer): TRetData; procedure FreeReturnData; procedure GetDimensions(var W, H: Integer); @@ -183,6 +184,20 @@ begin inherited; end; +function TMWindow.GetColor(x, y: integer): TColor; +begin + if Self.TargetMode = w_Window then + Result := GetPixel(Self.TargetDC,x,y) + else + begin + with ReturnData(x,y,1,1) do + Result := RGBToColor(Ptr[0].r,Ptr[0].g,Ptr[0].b); + FreeReturnData; + end; + + +end; + function TMWindow.ReturnData(xs, ys, width, height: Integer): TRetData; var {$IFDEF LINUX}