SRL Archive - OSR Help

FindBitmapRotated


serajin

2012-05-29 19:07:20

Hey Guys,

I'm having a bit of a hard time finding this function…It's mentioned in the bitmap tutorial. But almost nowhere else..

Is there something I am missing to access it?

Runaway

2012-05-29 20:09:03

I believe you have to use something along the lines of:


var
Bmp, x, y: Integer;
i: Extended;

//...

for i := 1 to 360 do
begin
if FindBitmap(Bmp, x, y) then
begin
//...
end else
RotateBitmap(Bmp, i);
end;

or


var
Bmp, x, y: Integer;
i: Extended;

//...

i := 0;
repeat
if FindBitmap(Bmp, x, y) then
begin
//...
end else
begin
IncEx(i, 2);
RotateBitmap(Bmp, i);
end;
end;

to do what you're looking for.

putonajonny

2012-05-31 16:59:03

FindBitmapRotated was a scar function that is not in simba, the tutorial you were following was probably for scar

Brandon

2012-05-31 17:34:26


Function FindBitmapRotated(var X, var Y: Integer; Bitmap, Tolerance: Integer; Area: TBox): Boolean;
var
I: Integer;
begin
For I:= 0 To 359 Do
begin
Result:= FindBitmapToleranceIn(Bitmap, X, Y, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
If Result then
Break;
Bitmap:= RotateBitmap(Bitmap, 1);
end;
end;

I'm not on a proper computer to test that but theoretically it should be identical.. I hope :S

putonajonny

2012-05-31 17:40:00

From: Brandon

Function FindBitmapRotated(var X, var Y: Integer; Bitmap, Tolerance: Integer; Area: TBox): Boolean;
var
I: Integer;
begin
For I:= 0 To 359 Do
begin
Result:= FindBitmapToleranceIn(Bitmap, X, Y, Area.X1, Area.Y1, Area.X2, Area.Y2, Tolerance);
If Result then
Break;
Bitmap:= RotateBitmap(Bitmap, 1);
end;
end;

I'm not on a proper computer to test that but theoretically it should be identical.. I hope :S


Btw are angles in degrees or radians?

Runaway

2012-05-31 17:41:35

From: putonajonny
Btw are angles in degrees or radians?


RotateBitmap is in degrees, as well as most of the angle-related functions.

bg5

2012-05-31 18:02:01

From: Runaway
RotateBitmap is in degrees, as well as most of the angle-related functions.

in this case in radians

I don't know if this works with angles != PI/2 * k , because then bitmap looks like:

,so black background becomes part of bitmap. It may work ,if bitmap finding function ignores clBlack.

And every new rotated bitmap is rectangle ,so if you rotate same bitmap multiple times at non 90 degree ,size of canvas will increase geometrically. Run this to understand ,what I'm talking about ,because it's hard to explain in english:rolleyes::
program new;
{$i srl/srl.simba}
{$I srl/srl/misc/debug.simba}
var
bmp ,a : integer;

begin
bmp := CreateBitmap(50,50);
FastReplaceColor(bmp,0,clred);
for a:= 0 to 9 do
begin
FastReplaceColor(bmp,0,a*2560);
debugbitmap(bmp);
wait(1000);
bmp := RotateBitmap(bmp,Radians(30));
end;
end.

Brandon

2012-05-31 18:27:22

From: beginner5
in this case in radians

I don't know if this works with angles != PI/2 * k , because then bitmap looks like:


Simba ignores black by default unless you settransparent to a different colour. Anything black by default is considered transparent. I thought it was degrees :S Why radians but yeah good idea though. :)

bg5

2012-06-01 04:47:31

btw.

If you ever gonna try to iterate same bitmap throught 360 degree
you will be eaten by
salad monster:

program new;
{$i srl/srl.simba}
{$I srl/srl/misc/debug.simba}
var
bmp ,bmp2 ,a : integer;
begin
bmp := CreateBitmap(50,50);
FastReplaceColor(bmp,0,clred);
for a:= 0 to 170 do
begin
FastReplaceColor(bmp,0,a*2560);
debugbitmap(bmp);
bmp2 := RotateBitmap(bmp,Radians(1));
Freebitmap(bmp);
bmp := bmp2;
end;
end.