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 unsupported format. |
4 |
4 bit compressed
DDS texture. |
8 |
8 bit palettized 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 bit alpha. |
8888 |
32 bit ARGB texture with 8 bit alpha. |
12 |
16 bit floating point format. |
14 |
32 bit floating point format. |
122 |
2x16 bit floating point format. A8
|
144 |
2x32 bit floating point format. A8 |
12222 |
4x16 bit floating point format. A7 |
14444 |
4x32 bit floating point format. A7 |
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
ARGB 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.
-
After locking an uncompressed bitmap, you can access its texture content directly through the bmap.finalbits pointer. The texture size (in bytes) is given through (mybmap.finalwidth * mybmap.finalheight * bmap.finalbytespp). The texture size is normally a power of 2 and not identical to the original image size returned by bmap_width and bmap_height.
-
Bitmap content can not be accessed on a stand-alone server, or before the first frame when the DirectX device is not yet opened.
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_format, bmap_to_format, pixel_to_bmap, pixel_for_bmap
► latest
version online