Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SimbaExt/SimbaExt.simba}
- //TRafBitmap is defined here: https://github.com/WarPie/SimbaExt/blob/master/ObjMode/TRafikiBitmap.pas
- function TRafBitmap.FindColor_CrashTheFuck(var TPA:TPointArray; Color:Integer; Area:TBox; Tolerance:Integer): Boolean;
- var
- Matrix: TIntMatrix; //just an Array of Array of Int32;
- begin
- //uncomment all code from here ... (maybe the first line uncomented is enough)
- if not(Self.IsLoaded('TRafBitmap.FindColorTol()')) then Exit; //Self.IsLoaded -> "Result := Self.Loaded; if not(Result) ..."
- if (Area.X2 >= Self.Width) then Area.X2 := Self.Width - 1
- else if (Area.X2 <= -1) then Area.X2 := Self.Width - Area.x2;
- if (Area.Y2 >= Self.Height) then Area.Y2 := Self.Height - 1
- else if (Area.Y2 <= -1) then Area.Y2 := Self.Height - Area.y2;
- if (Area.X1 > Area.X2) or (Area.Y1 > Area.Y2) then Exit;
- //... to here, then it doesn't seem to crash anymore?????
- Matrix := Self.ToMatrix(); //Wrapper that calls an Imported method
- //Matrix := Matrix.Area(Area.x1,Area.y1,Area.x2,Area.y2); //(issue not here) Wrapper that calls an FFI method
- Result := exp_ImFindColorTolEx(Matrix, TPA, Color, Tolerance); //FFI method
- end;
- var
- BMP:TRafBitmap;
- M:TIntMatrix;
- TPA:TPointArray;
- begin
- BMP.Open('tests/picture.png'); //any random picture that has some white ($FFFFFF) colors
- BMP.FindColor_CrashTheFuck(TPA,$FFFFFF,[0,0,BMP.Width-1,BMP.Height-1],1);
- Writeln(length(TPA)); //this call crashs it (Access violation).
- BMP.Free();
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement