Advertisement
WarPie90

Untitled

Aug 18th, 2014
484
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.55 KB | None | 0 0
  1. program new;
  2. {$I SimbaExt/SimbaExt.simba}
  3.  
  4. //TRafBitmap is defined here: https://github.com/WarPie/SimbaExt/blob/master/ObjMode/TRafikiBitmap.pas
  5.  
  6. function TRafBitmap.FindColor_CrashTheFuck(var TPA:TPointArray; Color:Integer; Area:TBox; Tolerance:Integer): Boolean;
  7. var
  8.   Matrix: TIntMatrix; //just an Array of Array of Int32;
  9. begin
  10.   //uncomment all code from here ... (maybe the first line uncomented is enough)
  11.   if not(Self.IsLoaded('TRafBitmap.FindColorTol()')) then Exit; //Self.IsLoaded -> "Result := Self.Loaded; if not(Result) ..."
  12.  
  13.   if (Area.X2 >= Self.Width) then Area.X2 := Self.Width - 1
  14.   else if (Area.X2 <= -1) then Area.X2 := Self.Width - Area.x2;
  15.  
  16.   if (Area.Y2 >= Self.Height) then Area.Y2 := Self.Height - 1
  17.   else if (Area.Y2 <= -1) then Area.Y2 := Self.Height - Area.y2;
  18.  
  19.   if (Area.X1 > Area.X2) or (Area.Y1 > Area.Y2) then Exit;
  20.   //... to here, then it doesn't seem to crash anymore?????
  21.  
  22.  
  23.   Matrix := Self.ToMatrix();                                      //Wrapper that calls an Imported method
  24.   //Matrix := Matrix.Area(Area.x1,Area.y1,Area.x2,Area.y2);       //(issue not here) Wrapper that calls an FFI method
  25.   Result := exp_ImFindColorTolEx(Matrix, TPA, Color, Tolerance);  //FFI method
  26. end;  
  27.  
  28.  
  29. var
  30.   BMP:TRafBitmap;
  31.   M:TIntMatrix;
  32.   TPA:TPointArray;
  33. begin
  34.   BMP.Open('tests/picture.png'); //any random picture that has some white ($FFFFFF) colors
  35.  
  36.   BMP.FindColor_CrashTheFuck(TPA,$FFFFFF,[0,0,BMP.Width-1,BMP.Height-1],1);
  37.  
  38.   Writeln(length(TPA)); //this call crashs it (Access violation).
  39.   BMP.Free();
  40. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement