BITMAP(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

πŸ’– NAME πŸ’–

BITMAP β€” the lil' struct that holds all the pixels of your bitmap, bestie. It lives in the Allegro game programming library, and it's genuinely the main character of everything you'll ever draw. ✨


🌸 SYNOPSIS 🌸

#include <allegro.h>

typedef struct BITMAP

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea, the fields you're actually allowed to touch look like this:

int w, h;               - size of the bitmap in pixels
int clip;               - non-zero if clipping is turned on
int cl, cr, ct, cb;     - clip rectangle left, right, top,
                          and bottom
unsigned char *line[];  - pointers to the start of each line

ngl there is some other stuff hanging out in the structure too πŸ™ˆ but that part is liable to change, so don't you dare use anything except the fields listed above. periodt. πŸ’…

The w and h fields are your besties for finding out how big an existing bitmap is, like:

bmp = load_bitmap("file.bmp", pal);
allegro_message("Bitmap size: (%dx%d)\n", bmp->w, bmp->h);

Now the clipping rectangle, and this is the part that trips people up, so pay attention bestie πŸ‘€ β€” it's inclusive on the left and top (so 0 lets you draw at position 0) but exclusive on the right and bottom (so 10 lets you draw at position 9, but not at 10). And no, it is not the same format as the clipping API, which takes inclusive coordinates for all four corners. it's giving "why are they different" and honestly? no clue, just remember it. 😭

All the values in this structure should be treated as read-only, with exactly one exception: the line field, and the whole deep dive on how to access that lives in the "Direct access to video memory" section of the manual. iykyk. πŸ“–

And if you wanna modify the clipping region? do NOT just change this structure. please, for the love of everything, refrain. Use set_clip_rect() instead. 🫢

πŸ‘‘ SEE ALSO πŸ‘‘


and that's the whole vibe, bestie πŸ’– this page is from the Allegro manual, version 4.4.3 β€” slay, go make something pretty with it. πŸŽ€βœ¨πŸ¦‹

πŸ“¦ where this page comes from