The Allegro Wiki is migrating to github at


From Allegro Wiki
Jump to: navigation, search



An ALLEGRO_BITMAP represents an image that can be drawn on and drawn to other bitmaps or windows.



Gets the ALLEGRO_GRAPHICS object used to draw to this bitmap. <highlightSyntax language="c"> ALLEGRO_GRAPHICS *al_get_bitmap_graphics(ALLEGRO_BITMAP *bitmap); </highlightSyntax>


Gets the width of the bitmap in pixels. <highlightSyntax language="c"> int al_get_bitmap_width(ALLEGRO_BITMAP *bitmap); </highlightSyntax>


Gets the height of the bitmap in pixels. <highlightSyntax language="c"> int al_get_bitmap_height(ALLEGRO_BITMAP *bitmap); </highlightSyntax>


Returns the pixel format of the bitmap. See al_create_window on the NewAPI/AlternativeWindow page for valid pixel formats. <highlightSyntax language="c"> int al_get_bitmap_format(ALLEGRO_BITMAP *bitmap); </highlightSyntax>


Gets the flags that were used to create this bitmap. <highlightSyntax language="c"> int al_get_bitmap_flags(ALLEGRO_BITMAP *bitmap); </highlightSyntax>



Set the mask color to use when drawing bitmaps with the ALLEGRO_MASK_SOURCE flag. This can be different than the color used for al_convert_mask_to_alpha and alpha can be combined with masking. <highlightSyntax language="c"> void al_set_bitmap_mask_color(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *color); /*

* Example usage:
* al_set_bitmap_mask_color(bitmap, al_map_rgb(al_get_bitmap_graphics(bitmap), &my_color, 255, 0, 255));

</highlightSyntax> This will set the mask color to magic pink for one particular bitmap format only. If you wish to use magic pink on a bitmap with a different format, you must re-set the mask color using that bitmap as the first parameter.


Retrieve a copy of the current mask color. color must point to an allocated ALLEGRO_COLOR structure. <highlightSyntax language="c"> ALLEGRO_COLOR *al_get_bitmap_mask_color(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *color); </highlightSyntax>



Creates a sub-bitmap of the parent, at the specified coordinates and of the specified size. A sub-bitmap is a bitmap that shares drawing memory with a pre-existing (parent) bitmap, but possibly with a different size and clipping settings.

If the sub-bitmap does not lie completely inside the parent bitmap, then it is automatically clipped so that it does.

The parent bitmap's clipping rectangles are ignored.

If a sub-bitmap was not or cannot be created then NULL is returned.

Note that destroying parents of sub-bitmaps will not destroy the sub-bitmaps; instead the sub-bitmaps become invalid and should no longer be used. <highlightSyntax language="c"> ALLEGRO_BITMAP *al_create_sub_bitmap(ALLEGRO_BITMAP *parent, int x, int y, int w, int h) </highlightSyntax>