Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program new;
- {$I SRL/OSR.simba}
- function FindBankSlots(color:Int32=3424329; tol:Int32=45): TBoxArray;
- var
- bmp,w,h,x,y,i,j:Int32;
- arr:array of record top,btm:Int32; end;
- temp:TIntegerArray;
- rows:TBoxArray;
- clear:Boolean;
- B:TBox;
- client:TBox = [73,81,456,293];
- begin
- rows := client.Partition(1,8);
- rows.ModifySide('x2',-15);
- bmp := BitmapFromClient(client.x1,client.y1, client.x2,client.y2);
- GetBitmapSize(bmp, W,H);
- //find all lines where there are no obstacles
- // -> The vertical separation between items
- for y:=0 to H-1 do
- begin
- clear := True;
- for x:=0 to W-1 do
- if not SimilarColors(FastGetPixel(bmp,x,y),color,tol) then
- begin
- clear := False;
- break;
- end;
- if clear then
- temp.Append(y);
- end;
- FreeBitmap(bmp);
- //find the upper and the lower part of the vertical separation line
- SetLength(arr, Length(temp));
- for i:=0 to High(temp)-1 do
- begin
- y := temp[i];
- while (temp[i] = temp[i+1]-1) and (i < High(temp)) do Inc(i);
- arr[j].top := y;
- arr[j].btm := temp[i];
- Inc(j);
- end;
- arr[j].top := temp[high(temp)];
- arr[j].btm := arr[j].top;
- //compute the resulting boxes
- for i:=0 to j-1 do
- for j:=0 to High(rows) do
- begin
- B := rows[j];
- B.y1 := client.y1 + arr[i+0].btm + 1;
- B.y2 := client.y1 + arr[i+1].top;
- if Abs(B.y1-B.y2) > 3 then
- Result.Append(B);
- end;
- end;
- var
- arr:TBoxArray;
- bmp,i:Int32;
- begin
- while 1 do
- begin
- bmp := BitmapFromClient(0,0,764,502);
- arr := FindBankSlots();
- for i:=0 to High(arr) do
- if (arr[i].Width > 1) and (arr[i].Height() > 1) then
- DrawTPABitmap(bmp, EdgeFromBox(arr[i]), 255);
- ShowBitmap(bmp);
- FreeBitmap(bmp);
- end;
- end.
Add Comment
Please, Sign In to add comment