ALLEGRO_LOCKED_REGION(3alleg5)
β¨ ALLEGRO_LOCKED_REGION β¨
okay bestie so this is a page from the Allegro 5 API reference manual, and it's all about ALLEGRO_LOCKED_REGION π pull up a chair, this one's short and sweet but lowkey important.
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
typedef struct ALLEGRO_LOCKED_REGION ALLEGRO_LOCKED_REGION;
π DESCRIPTION π
so here's the vibe: if you wanna manually edit or read from a bitmap, you literally have to lock it first. no skipping that step, bestie, it's giving non-negotiable π
The ALLEGRO_LOCKED_REGION structure is what represents the locked region of the bitmap. and the slay part? this call will work with any bitmap, including memory bitmaps. every single one. periodt. π
typedef struct ALLEGRO_LOCKED_REGION {
void *data;
int format;
int pitch;
int pixel_size;
} ALLEGRO_LOCKED_REGION;
now let's break down the members, one by one, because they all matter:
dataβ this points to the leftmost pixel of the first row (row 0) of the locked region. and heads up for the blocked formats girlies: for those, it points to the leftmost block of the first row of blocks. not a pixel. a block. iykyk π§formatβ tells you the pixel format of the data. that's it, that's the whole job πpitchβ this one's the size in bytes of a single row (you might also hear it called the stride). and listen, the pitch can totally be greater thanwidth * pixel_sizebecause of padding β and ngl that's not uncommon at all. it's also not uncommon for the pitch to be negative, because your bitmap might just be upside down π (iconic behaviour honestly). and for blocked formats?rowmeans the row of blocks, not of pixels. don't get it twisted.pixel_sizeβ the number of bytes used to represent a single block of pixels for the pixel format of this locked region. for most formats this is just the size of a single pixel β and historically, that used to be true for all formats, fr fr β but for blocked pixel formats this value is different. so yeah, check before you assume bestie π
lowkey reminder: the pitch being bigger than width * pixel_size is normal, and a negative pitch is normal too. not a bug, just the vibe. don't panic π«Ά
π¦ SEE ALSO π¦
al_lock_bitmap(3alleg5)al_lock_bitmap_region(3alleg5)al_unlock_bitmap(3alleg5)ALLEGRO_PIXEL_FORMAT(3alleg5)
and that's the whole page, bestie!! go forth and lock those bitmaps responsibly π this was from the Allegro reference manual, ALLEGRO_LOCKED_REGION(3alleg5), mwah πβ¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms