al_lock_bitmap(3)
πΈ NAME πΈ
al_lock_bitmap β Allegro 5 API. Welcome to the Library Functions Manual, bestie β this is the al_lock_bitmap(3) page, and today weβre locking entire bitmaps for reading or writing π
β¨
β¨ SYNOPSIS β¨
#include <allegro5/allegro.h>
ALLEGRO_LOCKED_REGION *al_lock_bitmap(ALLEGRO_BITMAP *bitmap,
int format, int flags)
π DESCRIPTION π
Okay so al_lock_bitmap locks an entire bitmap for reading or writing, periodt. If the bitmap is a display bitmap, it will be updated from system memory after the bitmap is unlocked β unless it was locked read only, bestie. It 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. No cap π
Flags are:
ALLEGRO_LOCK_READONLYβ the locked region will not be written to. This can be faster if the bitmap is a video texture, as it can be discarded after the lock instead of uploaded back to the card. iconic.ALLEGRO_LOCK_WRITEONLYβ the locked region will not be read from. This can be faster if the bitmap is a video texture, as no data need to be read from the video card. You are required to fill in all pixels before unlocking the bitmap again, so be careful when using this flag. fr fr, fill every pixel.ALLEGRO_LOCK_READWRITEβ the locked region can be written to and read from. Use this flag if a partial number of pixels need to be written to, even if reading is not needed.
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. performance slay.
Note: While a bitmap is locked, you can not use any drawing operations on it (with the sole exception ofal_put_pixel(3)andal_put_blended_pixel(3)). literally do not try it, bestie π
π¦ 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)
π signed off by the Allegro reference manual Β· page al_lock_bitmap(3) Β· date: not listed in the original footer, so Iβm not inventing one, bestie π«Άβ¨
π¦ where this page comes from
- arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms