al_lock_bitmap man page

al_lock_bitmap — Allegro 5 API


#include <allegro5/allegro.h>

   int format, int flags)


Lock an entire bitmap for reading or writing. If the bitmap is a display bitmap it will be updated from system memory after the bitmap is unlocked (unless locked read only). Returns NULL if the bitmap cannot be locked, e.g. the bitmap was locked previously and not unlocked. This function also returns NULL if the format is a compressed format.

Flags are:

format indicates the pixel format that the returned buffer will be in. To lock in the same format as the bitmap stores its data internally, call with al_get_bitmap_format(bitmap) as the format or use ALLEGRO_PIXEL_FORMAT_ANY. Locking in the native format will usually be faster. If the bitmap format is compressed, using ALLEGRO_PIXEL_FORMAT_ANY will choose an implementation defined non-compressed format.

On some platforms, Allegro automatically backs up the contents of video bitmaps because they may be occasionally lost (see discussion in al_create_bitmap(3)'s documentation). If you're completely recreating the bitmap contents often (e.g. every frame) then you will get much better performance by creating the target bitmap with ALLEGRO_NO_PRESERVE_TEXTURE flag.

Note: While a bitmap is locked, you can not use any drawing operations on it (with the sole exception of al_put_pixel(3) and al_put_blended_pixel(3)).

See Also

ALLEGRO_LOCKED_REGION(3), ALLEGRO_PIXEL_FORMAT(3), al_unlock_bitmap(3), al_lock_bitmap_region(3), al_lock_bitmap_blocked(3), al_lock_bitmap_region_blocked(3)

Referenced By

al_get_pixel(3), al_is_bitmap_locked(3), ALLEGRO_LOCKED_REGION(3), al_lock_bitmap_blocked(3), al_lock_bitmap_region(3), al_put_pixel(3), al_unlock_bitmap(3).

Allegro reference manual