|
Supported formats: ".bmp", ".dds", ".dib", ".jpg", ".png", ".tga"
File name extension (if given) is ignored. The engine will search
for recognized extensions (jbm, bmp or jpg) and will load which ever
exists. If the engine finds more then one recognized extension
(for example grass.bmp and grass.jpg) it will load the file
which was most recently modified
If the specified bitmap was already loaded then it just retrieves
its handle (in that case it is exactly like STATE_bitmap_get_handle() )
transparent_index should be -1 for no transparent and 0
for removing the most frequent color in the bitmap (usually
the most used color is the background)
transparent_index==1 means remove the second most used color etc ...
Note the difference between this command and STATE_utilities_load_bitmap_from_file()
This command loads a bitmap into the engine, while STATE_utilities_load_bitmap_from_file()
is just an extension to the Win32 API making it easy to load a bitmap from
the disk and to get its HBITMAP handle (a Win32 type)
Important:
Bitmaps that are not it the power of two dimensions will be automatically resampled (this is because 3D cards can only handle dimensions that are of the power of two !).
This is why it is best to have all your bitmaps in the power of two dimensions.
Numbers of the power of two are: 1,2,4,8,16,32,64,128,256,512,1024
A bitmaps in the size of 128x256 is OK
A bitmap in the size of 100x200 is not OK and there for will be automatically resampled by the engine (consuming more time )
Though the engine does a good job in resampling the bitmaps, Corel PhotoPaint or Adobe PhotoShop are probably better ...
Meaning that it is better if you resample you bitmaps your self and let the engine handle only bitmaps that are in the power of two
Examples:
A-
note that we dont have to give the bitmap extension
if we do it is simply ignored
STATE_bitmap_load("c:\\bitmaps\\my_bitmap",-1);
B-
Load a bitmap and set the most used color as transparent
STATE_bitmap_load("c:\\bitmaps\\my_bitmap",0);
C-
Load a bitmap and set the second most used color as transparent
STATE_bitmap_load("c:\\bitmaps\\my_bitmap",1);
NOTE this case !
D-
This example has some good news and some bad news.
The good news is that if c:\\bitmaps\\grass27
is exactly the same as c:\\NEW_bitmaps\\grass27
Then we shouldnt worry about wasting memory by loading two identical bitmaps
When we try to load the second bitmap the engine
will see that it already has a bitmap with that name and
it will return the handle to the first loaded bitmap without doing anything.
The bad news is that if the bitmaps are different, the engine
wont overwrite the old one. It will just return the handle to the already
loaded bitmap without doing anything else.
handle1=STATE_bitmap_load("c:\\bitmaps\\grass27",-1);
handle2=STATE_bitmap_load("c:\\NEW_bitmaps\\grass27",-1);
if(handle1!=handle2) error_message(); Never happens
A solution for this in case we want to overwrite the old bitmap
is to first delete the old bitmaps and then to load the new one.
E-
If we have two bitmaps in the same directory one is called
my_bitmap.jpg and the other is called my_bitmap.bmp
handle=STATE_bitmap_load(my_bitmap.jpg,-1);
Note that the engine will load my_bitmap.bmp and not
my_bitmap.jpg. Thats because loading bitmaps in jpg format is much slower
And also because the jpg version of a bitmap is usually not as good as the original
(depending how much compression we used)
|