al_lock_bitmap
ALLEGRO_LOCKED_REGION *al_lock_bitmap(ALLEGRO_BITMAP *bitmap,
int format, int flags)
Introduced in 5.0.0
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.
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.
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.
ALLEGRO_LOCK_READWRITE - The locked region can be written to and read from.
'format' indicates the pixel format that the returned buffer will be in. To lock in the same format as the bitmap stores it's 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.
Note: While a bitmap is locked, you can not use any drawing operations on it (with the sole exception of al_put_pixel and al_put_blended_pixel).
See also: ALLEGRO_LOCKED_REGION, ALLEGRO_PIXEL_FORMAT, al_unlock_bitmap
Examples: ex_blend, ex_blit, ex_clip, ex_draw, ex_drawpixels, ex_filter, ex_logo, ex_membmp, ex_premulalpha
Most helpful discussions:
- About load bitmap (1)
- [A5] Reading from bitmaps is amazingly slow (1)
- [a5] pixel function benchmarks (1)
- Convert *bitmap to char buffer
- Bitmap usage with memset and memcpy
- Allegro5 and OpenGL. Problem with drawing Allegro primitives
- You're such a disappointment.
- using a photo to floofill a bitmap
- Problems porting to linux. Video crashes
- help: memory bitmap background image causing artifacts
Other recent discussions:
- Allegro color bitmap
- Same code - slow on Windows, fast on Linux - timer fires too slow?
- ALLEGRO_LOCKED_REGION confusion
- Steam Client interference / OpenGL
- Waves, with sines but no ALLEGRO_FLIP_VERTICAL
- Learning shaders, one and for all.
- ALLEGRO_THREAD
- Using ESCAPI with Allegro
- Color Condundrum
- Suggestions for optimization