Advertisement
WarPie90

Untitled

Oct 1st, 2023 (edited)
1,822
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.73 KB | None | 0 0
  1. program new;
  2.  
  3. var bmp: TMufasaBitmap;
  4.  
  5. function LoadExample(): TPointArray;
  6. var
  7.   p: TPoint;
  8.   ex: TMufasaBitmap;
  9. begin
  10.   bmp.Init(client.GetMBitmaps);
  11.   bmp.LoadFromFile('images/example.bmp');
  12.   bmp.ThresholdAdaptive(0,255, False, TM_Mean, 0);
  13.   bmp.FindColors(Result, 0);
  14.   bmp.DrawClear($FFFFFF);
  15.  
  16.   for p in Result do
  17.   begin
  18.     bmp.SetPixel(p.x,p.y, 0);
  19.   end;
  20. end;
  21.  
  22. procedure TMufasaBitmap.MarkArea(P: TPoint; Sz: Int32; color: Int32);
  23. var
  24.   i,test: Int32;
  25.   TPA: TPointArray;
  26. begin
  27.   TPA := TPAFromCircle(p.x,p.y, Sz);
  28.   FillEllipse(TPA);
  29.   for i:=0 to High(TPA) do
  30.   begin
  31.     if (not InRange(TPA[i].x, 0,Self.GetWidth()-1)) or (not InRange(TPA[i].y, 0,Self.GetHeight()-1)) then
  32.       continue;
  33.  
  34.     test := bmp.GetPixel(TPA[i].x, TPA[i].y);
  35.     if (test = $FFFFFF) then
  36.       bmp.SetPixel(TPA[i].x, TPA[i].y, color);
  37.   end;
  38. end;
  39.  
  40. var
  41.   i,j,wid,hei: Int32;
  42.   color: Int32;
  43.   H,S,L: Extended;
  44.   TPA,PTS: TPointArray;
  45.   colors: TIntegerArray;
  46.   ATPA: T2DPointArray;
  47.   xxx: Int32;
  48. begin
  49.   PTS := LoadExample();
  50.  
  51.   ShowBitmap(bmp);
  52.   //TerminateScript;
  53.  
  54.   for TPA in ClusterTPA(PTS, 12) do
  55.   begin
  56.     color := Random($FFFFFF);
  57.     ColorToHSL(color, H,S,L);
  58.     for j:=0 to High(TPA) do
  59.     begin
  60.       pts := TPAFromCircle(TPA[j].x,TPA[j].y, 3);
  61.       FillEllipse(pts);
  62.       FilterPointsBox(pts, 0,0, bmp.getWidth-1, bmp.getHeight-1);    
  63.  
  64.       colors := bmp.GetPixels(pts);
  65.  
  66.       bmp.DrawTPA(pts, $FFFFFF);
  67.       if xxx mod 2 = 0 then
  68.         DrawBitmapDebugImg(bmp);
  69.  
  70.       bmp.SetPixels(pts, colors);
  71.       bmp.MarkArea(TPA[j], 12, HSLtoColor(H,70,90));
  72.       bmp.SetPixel(TPA[j].x, TPA[j].y, HSLtoColor(H,90,15));
  73.       Inc(xxx);
  74.     end;
  75.   end;
  76.   ShowBitmap(bmp);
  77.  
  78.   bmp.Free();
  79. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement