pixel_to_bmap(BMAP* bmap,var x,var y,var pixel);
Writes a pixel at xy position into the given bmap.
Parameters:
bmap |
target bmap, must be locked. |
x,y |
the pixel position within the bmap,
0..width-1 resp. 0..height-1. |
pixel |
the pixel to be written. |
Speed:
Medium
Remarks
- !! For speed reasons this function is not safeguarded. Exceeding the bmap size
(for instance also by redefining d3d_texlimit)
will issue a crash error.
- Only normal 16, 24, or 32 bit bmaps
(TGA, PCX, or BMP format) can be written into.
Compressed DDS bmaps, or bmaps used as render target can not be modified.
- The bmap must be locked. The pixel format must
match the bmap format. Otherwise it has to be converted by pixel_for_vec.
-
Alternatively, texture content can be accessed directly through the bmap.finalbits pointer; details under bmap_lock.
- For updating the mipmaps on mipmapped bmaps, use the bmap_to_mipmap function.
If the bmap did not contain mipmaps, call bmap_to_mipmap before
drawing to it in order to create a mipmap chain, and call bmap_to_mipmap a
second time after unlocking for copying the modified image into the mipmaps.
Example (lite-C):
// draw a one-line border around a bmap
void bmap_drawborder(BMAP* bmap,COLOR* color,var alpha)
{
var pixel = pixel_for_vec(color,alpha,bmap_lock(bmap,0));
var width = bmap_width(bmap);
var height = bmap_height(bmap);
var i;
for (i=0; i<width; i++) {
pixel_to_bmap(bmap,i,0,pixel);
pixel_to_bmap(bmap,i,height-1,pixel);
}
for (i=0; i<height; i++)
{
pixel_to_bmap(bmap,0,i,pixel);
pixel_to_bmap(bmap,width-1,i,pixel);
}
bmap_unlock(bmap);
}
See also:
bmap_unlock, bmap_lock, pixel_for_bmap, pixel_for_vec, bmap_to_mipmap
► latest
version online