bmap_create(STRING* name): BMAP*

bmap_createpart(STRING* name, var x, var y, var width, var height): BMAP* A8.11

bmap_createblack(var width, var height, var format): BMAP*

Creates a bmap at runtime. bmap_create loads the content from an image file or from a cutout of an image , bmap_createblack creates a black bmap with given dimensions that can later be filled with a color. Objects created this way are automatically deleted on closing the engine, or by calling the ptr_remove function.

Parameters:

name - name (STRING* or char*) of an image file that defines width, height, format, and content of the bitmap; optionally followed by cutout coordinates.
x - horizontal offset from the image upper left corner of in pixels.
y - vertical offset from the image upper left corner of in pixels.
width - width of the bitmap in pixels.
height - height of the bitmap in pixels.
format - bitmap format (uncompressed formats only; see bmap_lock) or number of bits per pixel (8, 16, 24, 32).

Returns:

BMAP* pointer, or NULL if it could not be created.

Remarks:

Speed:

Slow

Example:

// splits an image file horizontally and vertically into several parts,
// and stores them as separate files
void bmap_split(STRING* name,var splits_x,var splits_y)
{
  BMAP* bSource = bmap_create(name); // load the bitmap
  var dx = bmap_width(bSource)/splits_x; // get width and heigt of a split
  var dy = bmap_height(bSource)/splits_y;
  var format = bmap_format(bSource);
  BMAP* bDest = bmap_createblack(dx,dy,format); // create the split bitmap
  var i,j;
  for(j=0; j<splits_y; j++)
    for(i=0; i<splits_x; i++)
  {
// copy content from the original image into the split part, and save it
    bmap_blitpart(bDest,bSource,NULL,NULL,vector(i*dy,j*dy,0),vector(dx,dy,0));
    bmap_save(bDest,str_printf(NULL,"split%i%i.bmp",(int)j,(int)i));
  }
}

See also:

BMAP, bmap_lock, bmap_to_format, ptr_remove

► latest version online