Advertisement
WarPie90

PixelEdgesTPA

May 6th, 2022 (edited)
1,006
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.82 KB | None | 0 0
  1. function TMufasaBitmap.PixelEdgesTPA(MinDiff: Integer): TPointArray;
  2. var
  3.   x,y,wid,hei,h: Int32;
  4.   hit: Boolean;
  5. begin
  6.   wid := Self.GetWidth() - 1;
  7.   hei := Self.GetHeight() - 1;
  8.   SetLength(Result, 1000);
  9.  
  10.   h := 0;
  11.   for y:=0 to hei do
  12.     for x:=0 to wid do
  13.     begin
  14.       hit := False;
  15.       if (X+1 < wid) then
  16.         if not SimilarColors(Self.GetPixel(x,y), Self.GetPixel(x+1,y), MinDiff) then
  17.           hit := True;
  18.  
  19.       if (not hit) and (Y+1 < hei) then
  20.         if not SimilarColors(Self.GetPixel(x,y), Self.GetPixel(x,y+1), MinDiff) then
  21.           hit := True;
  22.  
  23.       if hit then
  24.       begin
  25.         if h >= Length(Result) then
  26.           SetLength(Result, Length(Result)*2);
  27.  
  28.         Result[h].x := x;
  29.         Result[h].y := y;
  30.         Inc(h);
  31.       end;
  32.     end;
  33.  
  34.   SetLength(Result, h);
  35. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement