Log in

View Full Version : Loading bitmaps



Jason2gs
02-24-2007, 02:43 AM
Can someone give me a small example on how to get/use the bitmap masks from SRL's ItemList, please?

Oh, and what exactly is a "BitMapMask"?

NinjaTerrorist
02-24-2007, 03:03 AM
A tutorial on bitmap masks can be found here: http://www.srl-forums.com/forum/showthread.php?t=7042

And to use the item list you have include it at the top of your script and setup it, and example below should show you how to use it:


{.include SRL/SRL.scar}
{.include SRL/SRL/MISC/ItemList.scar}

begin
SetupSRL;
SetupItems; // SetupSRL & SetupItems
FindBitmap(x, y, AllItems[1].Bitmap);
end.



{************************************************* ******************************
procedure SetupItems;
By: WT-Fakawi
Description: Initialises the items array.
************************************************** *****************************}
procedure SetupItems;
begin

AllItems[1].Name:='onearrow';
AllItems[1].Bitmap:= BitmapFromString(37, 36,
'z78DAEDD8C109C0201044D196ACC2FE4B0AE414901C1D93E1 FD02' +
'1CC60FABEC18009066DEE41333B9C9766BD6EEF4B377A89D7 6A7D' +
'A3DCF9F0B4D33393FC1F6DDE49BB5BE97B4BB176BACB1C61A 6BAC' +
'B1C6DAD97D45DF9FFF0B5B9A64AF8E76ADF3A47B4E0200FEC 805F' +
'9DEFE60'
);


Just look in the list for all the items. ;)

Jason2gs
02-24-2007, 03:17 AM
Awesome :) Thanks.

Jason2gs
02-24-2007, 04:53 AM
So the following script should work?

program New;
{.include SRL/SRL.scar}
{.include SRL/SRL/MISC/ItemList.scar}

begin
SetupSRL;
SetupItems;

if(FindBitmapMaskTolerance(AllItems[18].Bitmap, x, y, 3, 3, 515, 338, 1, 1))then
MMouse(x, y, 2, 2);
Mouse(x, y, 0, 0, True);

end.

Boreas
02-24-2007, 04:56 AM
Mouse has MMouse in it, so just use Mouse(x,y,2,2,true).

Yea it should work. But instead of including the whole thing, just copy what you need into your script, loading all the bitmaps takes up memory. Also don't forget to free bitmaps.

Jason2gs
02-24-2007, 05:11 AM
How do I "free" the bitmaps? You make it sound like they're in a cage somewhere :p

Jason2gs
02-24-2007, 05:24 AM
I changed that script to this:

program New;
{.include SRL/SRL.scar}
{.include SRL/SRL/MISC/ItemList.scar}

begin
SetupSRL;
SetupItems;

AllItems[18].Bitmap:= BitmapFromString(37, 36,
'z78DAED97410E80200C04BFC42BF8FF93BC9A189AAD686DEB CC89' +
'1050262C55C600000000F82FF3443F2F6F4F0FBB55BB4A0E5 7767' +
'67F3653EFAA9491918ED3C43B4B597F8C9DF72DBA759E64EA 7B54' +
'B7665E73A524CD4EE63D62ECBEAD03914F7EDB2EC3F742C9D 24E0' +
'2739ED39D0A9CC74ED9B5BA99CCF0EF81DDB395ADD3FDAEB7 5DEF' +
'5B39000054E400819A0FF7'
);

if(FindBitmapMaskTolerance(AllItems[18].Bitmap, x, y, 3, 3, 515, 338, 1, 1))then
writeln('Found Bitmap');

end.

And it's still not working :(

It's compiling alright, but it's not finding it.

Boreas
02-24-2007, 05:30 AM
iIf this doesn't work play with the parameters.
program New;
{.include SRL/SRL.scar}
var bones:integer;

begin
SetupSRL;


bones:= BitmapFromString(37, 36,
'z78DAED97410E80200C04BFC42BF8FF93BC9A189AAD686DEB CC89' +
'1050262C55C600000000F82FF3443F2F6F4F0FBB55BB4A0E5 7767' +
'67F3653EFAA9491918ED3C43B4B597F8C9DF72DBA759E64EA 7B54' +
'B7665E73A524CD4EE63D62ECBEAD03914F7EDB2EC3F742C9D 24E0' +
'2739ED39D0A9CC74ED9B5BA99CCF0EF81DDB395ADD3FDAEB7 5DEF' +
'5B39000054E400819A0FF7'
);

if(FindBitmapMaskTolerance(bones, x, y, 3, 3, 515, 338, 1, 1))then
writeln('Found Bitmap');
freebitmap(bones);
end.

Hobbit
02-24-2007, 05:36 AM
A tutorial on bitmap masks can be found here: http://www.srl-forums.com/forum/showthread.php?t=7042

And to use the item list you have include it at the top of your script and setup it, and example below should show you how to use it:


ScarScript:By Drunkenoldma
</p><p>{.include SRL/SRL.scar}</p><p>{.include SRL/SRL/MISC/ItemList.scar}</p><p> </p><p>begin</p><p>SetupSRL;</p><p>SetupItems; // SetupSRL & SetupItems</p><p>FindBitmap(x, y, AllItems[1].Bitmap);</p><p>end.</p><p>




ScarScript:By Drunkenoldma
</p><p>{************************************************* ******************************</p><p>procedure SetupItems;</p><p>By: WT-Fakawi</p><p>Description: Initialises the items array.</p><p>************************************************** *****************************}</p><p>procedure SetupItems;</p><p>begin</p><p> </p><p>AllItems[1].Name:='onearrow';</p><p>AllItems[1].Bitmap:= BitmapFromString(37, 36,</p><p> 'z78DAEDD8C109C0201044D196ACC2FE4B0AE414901C1D93E1 FD02' +</p><p> '1CC60FABEC18009066DEE41333B9C9766BD6EEF4B377A89D7 6A7D' +</p><p> 'A3DCF9F0B4D33393FC1F6DDE49BB5BE97B4BB176BACB1C61A 6BAC' +</p><p> 'B1C6DAD97D45DF9FFF0B5B9A64AF8E76ADF3A47B4E0200FEC 805F' +</p><p> '9DEFE60'</p><p> );</p><p>



Just look in the list for all the items. ;)

hey thats my tut :D so did it help you any?

Jason2gs
02-24-2007, 05:36 AM
What does it mean to "free the bitmap"? It's already there, in the script.

Jason2gs
02-24-2007, 05:38 AM
hey thats my tut :D so did it help you any?

Tell ya the truth, I didn't stick around to read the whole thing.

But from what I saw, it looked nice ;)

Hobbit
02-24-2007, 05:40 AM
What does it mean to "free the bitmap"? It's already there, in the script.

ok when u put the bitmap in ur script its as bitmapfromstring:= etc so that loads the picture into your computers memory..free bitmap just unloads it

Jason2gs
02-24-2007, 05:50 AM
So if I want to use a bitmap, I have to first have the bitmap in the script, then free the bitmap? Confusing, but ok.

Hobbit
02-24-2007, 05:54 AM
no you dont need free bitmap i dont use it at all

heres example from 1 of my scripts im making
procedure Minimise;
var
x,y : integer;
begin
begin
minimiseBMP:= BitmapFromString(21, 21, 'z78DACD95DD' +
'0E83200C465FA985D69F4BDDF0FD1F69B525598984CC8B9AF 1252' +
'7A60E4F750AB0C1069C212D38F1449C389AE6828B17264986 B8A1' +
'D7F73D542F014302944038D5E59F86D61F4D632749D26038D 5D5B' +
'167493CFFCDEEEAE15457E7DE1F64C7CE703E85685EEDACDF BBAD' +
'36D1E4CBF76EF5F911BA15AFDAADBE48289CF3C5BE482DDBC A5FA' +
'9A360C1D7F20B9BB963AAABB1AFDAD52EE14A1DF21725F9CD 90D5' +
'EEE78EA9AEC6BE498DA048A6CABB763F774C7535F6D7D9956 E41B' +
'3F1EEE659E7E2F70A1DEA597335F6026FB16794372F9AE6F2 F674' +
'A41D0EDC7085359AE632AF54E46DF03D44D37B6D57F73D744 8941' +
'335C7BE7293DEFB01B0F51347');
end;
If(FindBitmapMaskTolerance(minimiseBMP,x,y,0,0,102 4,768,1,1))then
begin
Writeln('Minimise Found');
Wait(850);
ClickMouse(x,y,True);
end;
end;

Jason2gs
02-24-2007, 05:56 AM
Alright. So why do some people put it in there?

And where can I find a list of SRL's DTMs?

Hobbit
02-24-2007, 05:58 AM
im not sure why...but what do you mean "SRL's" DTMs? you make ur own DTMs for the object u need it for

Jason2gs
02-24-2007, 06:04 AM
There isn't a list of DTMs like there is a list of Bitmaps?

Hobbit
02-24-2007, 06:59 AM
no i dont think so...not one i've found

Jason2gs
02-24-2007, 07:01 AM
Alright.

Do other people mind if you use their DTMs?

Hobbit
02-24-2007, 07:09 AM
well you'll have to ask...i wouldn't mind if u used mine

Jason2gs
02-24-2007, 07:17 AM
Alright. Thanks =)