PDA

View Full Version : FindBitMapInBitmap Function?



CamHart
10-26-2006, 02:58 AM
Anyone have any idea's how i would find/make something happen like a FindBitmapInBitmap like while it still has the RS Client activated?

I'd like to take a picture of the Minimap, crop it so its just the minimap, rotate the minimap degrees, then search for bitmaps in it.

I have it working right now where the script just hits the over arrow, but if the computers slow i've figured out it makes it lag so bad that my function wont work with it.

I know how to use canvas to crop the minimap, i know how to rotate the cropped mini map, i just don't know how i would make SCAR search for a bitmap within that bitmap instead of the scar client.

Any help is greatful, even if all you say is "no idea." Then it means i can start googleing and learning pascal or w/e.

Boreas
10-26-2006, 03:05 AM
Yakman might know.

masquerader
10-26-2006, 05:04 AM
kk, good question

heres what you want to do:
first, copy the client handle to an integer so you can go back to it later:
Handle := GetClientWindowHandle;

initalize your bitmaps by doing:
ScreenBmp := BitmapFromString(Width, Height, '');

then copy the client to the bitmap:
CopyClientToBitmap(ScreenBmp, X1, Y1, X2, Y2);

you can then set the bitmap as the target for color/bitmap searching by using
SetTargetBitmap(ScreenBmp);

do your searching, then set the handle back with
SetClientWindowHandle(Handle);

thats probably what you want
there are ways of manipulating canvases with ellipses so you get only the minimap and not the border, but thats kinda tricky even for me

look at findcolorellipse in srl for how to do that, or this little program i made out of it with a debug window


program aweso;

procedure DebugEllipse(X1, Y1, X2, Y2: Integer);
var
Debug,Temp: TCanvas;
H, W, ScreenBmp, TempBmp: Integer;
begin
W := Max(X1, X2) - Min(X1, X2);
H := Max(Y1, Y2) - Min(Y1, Y2);
TempBmp := BitmapFromString(W, H, '');
Temp := GetBitmapCanvas(TempBmp);
ScreenBmp := BitmapFromString(W, H, '');

FastDrawClear(TempBmp, -1);
CopyClientToBitmap(ScreenBmp, X1, Y1, X2, Y2);

CopyCanvas(GetBitmapCanvas(TempBmp), Temp, 0, 0, W, H, 0, 0, W, H);
Temp.Ellipse(0, 0, W, H);
CopyCanvas(Temp, GetBitmapCanvas(TempBmp), 0, 0, W, H, 0, 0, W, H);
SetTransparentColor(TempBmp, 16777215);
FastDrawTransparent(0, 0, TempBmp, ScreenBmp);

displaydebugimgwindow(w,h);
debug:=getdebugcanvas;
copycanvas(getbitmapcanvas(screenbmp),debug,0,0,w, h,0,0,w,h);

FreeBitmap(TempBmp);
FreeBitmap(ScreenBmp);
end;

begin
debugellipse(575,9,720,143)
end.

edit: sorry, i didnt read that you already know how to do that, all you need is the
SetTargetBitmap(ScreenBmp);

Boreas
10-26-2006, 05:22 AM
Don't worry, good for people who don't know that part (me).

lardmaster
10-26-2006, 09:18 PM
ahh, make a DTM which is just a bitmap and do findDTMrotated()! it does it all for you!

CamHart
10-26-2006, 09:36 PM
Thanks a bunch!

CamHart
10-27-2006, 09:51 PM
Yea that ellipse thing is better than what i was doing lol, so ill toss it it :D Ty