PDA

View Full Version : FindBitmapInCircle?



CamHart
10-31-2006, 04:25 AM
Sorry for asking again, I've got a way to get the Road Color, and it works right now, but it would work.... a little better if i had a function like FindBitmapInCircle or something where it only searched for the bitmap in the circle instead of a quadrilater.

Sorry for all the questions, I've got limited time on the computer right now (Football in state playoffs n such), so the little time i have away from school, church (more time consuming than you'd expect), sports, family, and friends, i'd prefer to be scripting instead of researching code to make it.

FindBitmapInCircle(Bitmap, x, y, Centerx, centery, radius:integer):boolean

Any and all help is appreciated.

masquerader
10-31-2006, 10:52 PM
i cant believe freddy didnt write a plugin or something to do this :P
oh well, here you go
it should work, i dunno


function FindBitmapInCircleTol(bitmap:integer; var x, y: Integer; Centerx, Centery, Radius, Tol:integer): Boolean;
var
Temp: TCanvas;
Cx, Cy, H, W, ScreenBmp, TempBmp, Handle: Integer;
begin
W := 2*Radius;
H := 2*Radius;
Handle := GetClientWindowHandle;
TempBmp := BitmapFromString(W, H, '');
Temp := GetBitmapCanvas(TempBmp);
ScreenBmp := BitmapFromString(W, H, '');
FastDrawClear(TempBmp, -1);
CopyClientToBitmap(ScreenBmp, CenterX-Radius, CenterY-Radius, CenterX+Radius, CenterY+Radius);
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);
SetTargetBitmap(ScreenBmp);
X := -1;
Y := -1;
Cx := W div 2;
Cy := H div 2;
if FindBitmapSpiralTolerance(Bitmap, Cx, Cy, 0, 0, W, H, Tol) then
begin
X := Cx+CenterX-Radius;
Y := Cy+CenterY-Radius;
Result := true;
end;
SetClientWindowHandle(Handle);
FreeBitmap(TempBmp);
FreeBitmap(ScreenBmp);
end;

CamHart
10-31-2006, 11:49 PM
Thanks a bunch :D <3