The Allegro Wiki is migrating to github at

Al create sub bitmap

From Allegro Wiki
Jump to: navigation, search


al_create_sub_bitmap - creates a sub-bitmap from a parent

C Specification

AL_BITMAP *al_create_sub_bitmap(AL_BITMAP *parent, int x, int y, int w, int h)


parent The parent bitmap
x, y The top left position of the sub-bitmap within the parent bitmap
w, h The width and height of the sub-bitmap


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.

When creating a sub-bitmap of a mode-X display bitmap, the x position must be a multiple of four.

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.


Destroying parents of sub-bitmaps will not destroy the sub-bitmaps; instead the sub-bitmaps become invalid and should no longer be used.


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

API Branch


See Also