create_bitmap_ex(3alleg4)

πŸ’– create_bitmap_ex β€” NAME πŸ’–

okay bestie, so create_bitmap_ex is the Allegro function that creates a memory bitmap and lets you pick the color depth yourself. yes queen, you get to choose. it's part of the Allegro game programming library, so it's giving very much "i make graphics happen" energy 🎨✨


πŸŽ€ SYNOPSIS πŸŽ€

#include <allegro.h>

BITMAP *create_bitmap_ex(int color_depth, int width, int height);

✨ DESCRIPTION ✨

so here's the tea πŸ«–: this function makes you a bitmap in a specific color depth β€” and the depths you can pick from are literally 8, 15, 16, 24 or 32 bits per pixel. pick your fighter, they're all valid πŸ’…

here's a lil example so you can see it in the wild, no cap:

/* Create screen sized bitmap in 32 bits per pixel. */
BITMAP *bmp = create_bitmap_ex(32, SCREEN_W, SCREEN_H);
if (!bmp)
   abort_on_error("Couldn't create bitmap!");
/* Use the bitmap. */
...
/* Destroy it when we don't need it any more. */
destroy_bitmap(bmp);

see how it's giving "make a screen-sized bitmap at 32bpp, check it actually worked, use it, then clean up after yourself"? that's the whole arc πŸ¦‹ main character behaviour fr fr.


🌸 RETURN VALUE 🌸

it hands you back a pointer to the created bitmap πŸ’š … or NULL if the bitmap just could not be created 😭 (rude, but okay).

⚠️ and bestie, please β€” remember to free this bitmap later so you don't leak memory. destroy_bitmap(bmp), be responsible, we don't do leaks in this house 🫢

πŸ‘‘ SEE ALSO πŸ‘‘

go read these next, iykyk:


and that's the whole page, bestie 🌈 this was Allegro version 4.4.3, page create_bitmap_ex(3alleg4). go forth and allocate responsibly πŸ’œπŸ’–βœ¨