BITMAP(3alleg4)
π BITMAP π
okay bestie, welcome to the Allegro manual (3alleg4), and today's main character is BITMAP β the little struct that literally stores the contents of a bitmap in the Allegro game programming library. no cap. let's get into it β¨
πΈ SYNOPSIS πΈ
#include <allegro.h>
typedef struct BITMAP
π¦ DESCRIPTION π¦
so the struct looks like this, and yes we're reading it top to bottom like a group chat:
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
okay so, breaking it down:
int w, h;β the size of the bitmap, in pixels πint clip;β non-zero if clipping is turned onint cl, cr, ct, cb;β the clip rectangle: left, right, top, and bottomunsigned char *line[];β pointers to the start of each line
there is some other stuff in the structure as well, but it is liable to change and you shouldn't use anything except the above. periodt. do not touch the mystery fields. π
the w and h fields can be used to obtain the size of an existing bitmap, like so:
bmp = load_bitmap("file.bmp", pal);
allegro_message("Bitmap size: (%dx%d)\n", bmp->w, bmp->h);
now the clipping rectangle lore, because this is where people get got: it is inclusive on the left and top (0 allows drawing to position 0) but exclusive on the right and bottom (10 allows drawing to position 9, but not to 10). note this is not the same format as that of the clipping API, which takes inclusive coordinates for all four corners. so likeβ¦ don't mix them up, bestie π
all the values of this structure should be regarded as read-only, with the one exception of thelinefield, whose access is described in depth in the"Direct access to video memory"section of the manual. if you want to modify the clipping region, please refrain from changing this structure. useset_clip_rect()instead. slay responsibly π
β¨ SEE ALSO β¨
create_bitmap(3alleg4)set_clip_rect(3alleg4)bitmap_color_depth(3alleg4)RLE_SPRITE(3alleg4)COMPILED_SPRITE(3alleg4)
and that's the whole page, gorgeous π«Ά this was Allegro, version 4.4.3, serving you BITMAP(3alleg4) realness. go forth and never write to a struct field you weren't supposed to. mwah π
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms