Advertisement
WarPie90

FindMMDots Super

Jul 8th, 2018
493
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.73 KB | None | 0 0
  1. function FindMMDots(BMP: TMufasaBitmap): TPointArray;
  2.   function FindDots(blacks: TPointArray; Color, T: Int32): TPointArray;
  3.   var
  4.     i: Int32;
  5.     p: TPoint;
  6.   begin
  7.     for i:=0 to High(blacks)-1 do
  8.       if (BMP.GetPixel(blacks[i].x+3,blacks[i].y+0) = 65536)   or
  9.          (BMP.GetPixel(blacks[i].x+2,blacks[i].y+1) = 65536) then
  10.       begin
  11.         p := blacks[i];
  12.         p.y -= 3;
  13.         if Ord(SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+0), t)) +
  14.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+0), t)) +
  15.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+0,p.y+1), t)) +
  16.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+1), t)) +
  17.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+1), t)) +
  18.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+3,p.y+1), t)) +
  19.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+0,p.y+2), t)) +
  20.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+2), t)) +
  21.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+2), t)) +
  22.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+3,p.y+2), t)) +
  23.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+1,p.y+3), t)) +
  24.            Ord(SimilarColors(Color, BMP.GetPixel(p.x+2,p.y+3), t)) >= 8 then
  25.         begin
  26.           Result += p;
  27.         end;
  28.       end;
  29.   end;
  30. var
  31.   blacks: TPointArray;
  32. begin
  33.   BMP.FindColors(blacks, 65536);
  34.   blacks := blacks.FilterBox(Box(1,4,BMP.GetWidth-4, BMP.GetHeight-1));
  35.  
  36.   SetColorToleranceSpeed(2);
  37.   SetToleranceSpeed2Modifiers(0.001,0.001);
  38.   Result := FindDots(blacks, $FFFFFF, 30); //white
  39.  
  40.   SetColorToleranceSpeed(2);
  41.   SetToleranceSpeed2Modifiers(0.05,1);
  42.   Result += FindDots(blacks, $00FFFF, 30); //yellow
  43.   Result += FindDots(blacks, $0000FF, 30); //red
  44. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement