Bitmaps:
What are Bitmaps?:
A set of bits that represents a graphic image, with each bit or group of bits corresponding to a pixel in the image.
To sum that all up, a bitmap is a image with a high quality, which makes it idle for SCAR's built in image searching functions/procedures.
How do you capture the image?
If you don't have image capturing software, you can simply use the "Prnt Scrn" button, usually located in the upper right of your keyboard.
If you only want to capture the currently selected window, then you can hit Alt + Prnt Scrn, this reduces the amount of cropping/editing you will have to do later.
Ok, now that you know how to capture an image, lets get an example to use for this tutorial, which in this case will be a willow log from RuneScape 2.
So open up RuneScape and capture an image similar to this one:
I would recommend that for the sack of following along with this tutorial you use the above image also, you may notice that it is a .png instead of a .bmp, well that is because imageshack.us automatically converts a .bmp to a .png. But none the less, it will work.
Anyway, open the Inventory image up in paint or your favorite image editing software (I chose paint because this part is very quick, and you don't need any resource intensive software like PhotoShop to do it.
Anyway, open Paint up and select one of the willow logs, like so:
And then copy or cut it onto your "clipboard", and open up a new Paint, and paste the willow log there. Now make sure the paint pallet is as small as possible, so there is no added white space to your image, as this will increases the size of your bitmap and cause more lag and memory usage, which isn't good at all.
Ok so now you should have a Paint open that looks like so:
Now it is time to make it ready for SCAR. Now a little knowledge for you...
SCAR doesn't register black in it's bitmaps, it ignores black. So lets make it happen.
You see how there is a bunch of extra space around the log, well we don't want SCAR to look for that too, so we are going to black that part out. So select your "Bucket" tool and fill the non-willow log part of the bitmap with black like so:
Now it is time to make the image smaller, yes smaller. The golden rule in bitmaps is the smaller the better. Try to balance efficiency with size. Ok, so now we are going to attempt to make the image smaller by getting as close to the edge of the willow log as possible without removing any part of it. To do this you might want to zoom into the image in Paint by hitting Ctrl+ Page Dn.
So now zoom in and use the select/cut tool to crop the image even closer. Here were my results:
Now it is time to open the bitmap in SCAR!
To do this Open up SCAR, and go to 'Tools' ---> 'Picture to String...'
You should be presented with a menu resembling the following:
Now hit open, and find the saved bitmap that you have just created. Make sure the entire image is selected and hit "Ok".
You should now be presented with a whole mess of jumbled letters and numbers in your debug box, that should look similar to this:
SCAR Code:
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
Now Lets turn this into a working bitmap finder.
To start of you have SCAR load your bitmap before it can use it, so lets create a procedure and call it "LoadBitmap", straightforward, huh?
And lets copy the bitmap from the debug box and paste it within the procedure, so select the bitmap text and hit CTRL + C (this is the keyboard shortcut for 'copy').
You should have code that look like this:
SCAR Code:
program New;
procedure LoadBitmap;
begin
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
end;
begin
end.
Ok, now that you have the bitmap loaded, you have to declare the bitmap name as a variable, so lets do that.
In this case we will declare it as what is called a 'Global Variable'.
To do this add the command 'Var', about one to two spaces below 'Program', so that should like like this:
SCAR Code:
program New;
var
procedure LoadBitmap;
begin
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
end;
begin
end.
Now we have to declare our bitmap "WillowLog2" as a variable. Bitmaps are declared as integers. So lets do it...
SCAR Code:
program New;
var
WillowLog2: integer;
procedure LoadBitmap;
begin
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
end;
begin
end.
Now that we have the bitmap declared and ready for use, lets search for it!
If you look at your list of Bitmap function, you will see
"function FindBitmapToleranceIn(bitmap: Integer; var x, y: Integer; x1, y1, x2, y2: Integer; tolerance: Integer): Boolean;"
And you guessed it, this is what we will use to search for the willow log in the RuneScape inventory.
This function my seem complicated, but really it is extremely easy to use. To start off, lets make a procedure to find our bitmap, so creat a new procedure and lets name it "FBitmap". So our script should look like this:
SCAR Code:
program New;
var
WillowLog2: integer;
procedure LoadBitmap;
begin
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
end;
procedure FBitmap;
begin
end;
begin
Now let me show you how to fill out the function 'FindBitmapToleranceIn':
bitmap: Integer; - This is the name of you bitmap, in this case "WillowLog2"
var x, y: Integer; - These are the variables that will be returned for the position of the found bitmap, this is useful when you want to click the bitmap, or interact with it after it is found.
Integer; x1, y1, x2, y2: Integer; - These are the coordinates for the "box" that SCAR will search for the bitmap in. This is very useful to not only save time when searching for bitmaps (because SCAR has to search less of the selected client), but also reduces memory usage and lag. In our case, since we are searching for the willow logs in the inventory, we will be using the coordinateness 560, 214, 734, 457
tolerance: Integer - this is the amount that the color can change and still be recognized, you want as low a number as possible, so you don't have other colors interfering. I recommend a tolerance of about 20 - 30.
Ok so now that we understand the different parts of 'FindBitmapToleranceIn', lets fill it out and add it to our script. So lets add:
Code:
FindBitmapToleranceIn(WillowLog2, x, y, 560, 214, 734, 457, 25);
to our script:
SCAR Code:
program New;
var
WillowLog2: integer;
procedure LoadBitmap;
begin
WillowLog2 := BitmapFromString(31, 25, 'beNqtlkFLAzEUhJujWBS' +
'V6qUHeyhqUcuKFUUKVihUFEVRoSAUPPn/f4GzjAyv+zZpsLvMoTTd' +
'L5O8eUlbrfWesKymnpJ22N3o9zYH/fbwZOvyfLshfhBzPNq9Lnagb' +
'HhIC5zJzR6wVnnw8l1YguANDmUS9gAB1isPHt4eBx/Pp1/vw+m4Q3' +
'mUhjRK+EGnneSH7/kF9XC37/kWa0U4VpcPt3yJ31sJvnJbBF98Fpb' +
'vmRJWhHKssl0PT4g7RtsoeryV/mImuN2cGJPxZq6gyW3vqug6fmAj' +
'QAmyiissxReZdtNNnCI8TY+wCWoHkm0aGXuPUuxVFzs7p0C2AQdt/' +
'nrGH5Msbx7rw+l3jPCfxYhWBUcfvcyOKw3urfp8erjiITjnwhSxro' +
'kl38PBIRwfaDuW9pyGqsBh2MJtYBLwvIYqCyo4bOc4r00pc8iz1KS' +
'95MM/hBXN7vu1fZooH5S88paGYq1kz0kHzL3FrHOZ19G99o0cKtvS' +
'BLPKp+Gm/zlUCvGv5xdCwRWZ');
end;
procedure FBitmap;
var
x, y :integer;
begin
FindBitmapToleranceIn(WillowLog2, x, y, 560, 214, 734, 457, 25);
end;
begin
end.
As you might have noticed, I have added the variables 'x' and 'y' to the "Local variables", you need to do this in order for this script to compile and work. "Local Variables" work the same as Global Variables except they can't be used outside of the specified procedure/function.
Now You just add our procedure 'Fbitmap' to the mainline, and there you go, you have your very own bitmap searching script.
Congratulations!