bmap_lock(BMAP* bmap,var mode)
Preloads and locks a bitmap and returns its texture format. Mostly used for writing
into or reading from a bitmap.
Parameters:
| bmap |
name or pointer of a bmap |
| mode |
always 0 |
Returns:
| 0 |
invalid bitmap or unknown format. |
| 4 |
4 bit compressed ARGB texture. |
| 88 |
16 bit UV texture, for effects or shaders. |
| 565 |
16 bit RGB texture without alpha transparency. |
| 888 |
24 bit RGB texture without alpha transparency. |
| 1555 |
16 bit ARGB texture with 1 bit alpha, for sprites or overlays. |
| 4444 |
16 bit ARGB texture with 4 bits alpha. |
| 8888 |
32 bit ARGB texture with 8 bits alpha. |
Speed:
Medium
Remarks:
- The returned format depends on the use of the bitmap and its original image format.
DDS images produce compressed textures, PCX and BMP images produce 16 bit textures
and TGA images produce 24 or 32 bit textures. Pixel instructions only work with
the format 565 or above.
- Render target bitmaps must be converted through bmap_to_format before
they can be locked.
- A bitmap must be unlocked for being visible on
the screen.
Example:
// paint a red cross into a bmap
var format;
var pixel;
format = bmap_lock(tgablitz,0);
if (format >= 565) {
pixel = pixel_for_vec(vector(0,0,255),100,format); // red color
pixel_to_bmap(tgablitz,10,10,pixel);
pixel_to_bmap(tgablitz,10,11,pixel);
pixel_to_bmap(tgablitz,10,12,pixel);
pixel_to_bmap(tgablitz,10,13,pixel);
pixel_to_bmap(tgablitz,10,14,pixel);
pixel_to_bmap(tgablitz,8,12,pixel);
pixel_to_bmap(tgablitz,9,12,pixel);
pixel_to_bmap(tgablitz,11,12,pixel);
pixel_to_bmap(tgablitz,12,12,pixel);
}
bmap_unlock(tgablitz); // unlock the locked bitmap
See also:
bmap_unlock, bmap_to_format, pixel_to_bmap, pixel_for_bmap