create_bitmap(3alleg4)
π create_bitmap π
okay bestie, so this is a page from the Allegro manual β yes, the Allegro game programming library, we're being β¨productiveβ¨ today β and it's all about the function create_bitmap. Let's get into it, i promise it's not scary π«Ά
β¨ NAME β¨
create_bitmap β makes you a memory bitmap π¨ Allegro game programming library energy, periodt.
πΈ SYNOPSIS πΈ
#include <allegro.h>
BITMAP *create_bitmap(int width, int height);
π DESCRIPTION π
So basically, create_bitmap creates a memory bitmap that's width by height. That's it. That's the vibe. π
Here's the tea tho, and you're gonna wanna hear this:
- The bitmap comes with clipping turned on, and the clipping rectangle is set to the full size of the bitmap. So it's ready to go, no extra setup.
- the image memory will NOT be cleared. not me finding out the hard way π it will probably contain garbage, so like... bestie, please clear the bitmap before you use it. fr fr. don't skip this step.
- this routine always uses the global pixel format, as specified by calling
set_color_depth(). - the minimum height of the
BITMAPmust be1, and width can't be negative. that's the rule, no cap π«
Here's the example, verbatim, because i would never mess with your code:
/* Create a 10 pixel tall bitmap, as wide as the screen. */
BITMAP *bmp = create_bitmap(SCREEN_W, 10);
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);
look at that. iconic. the SCREEN_W for width and 10 for height, the null check with abort_on_error, and then destroy_bitmap when you're done. main character energy honestly π
π RETURN VALUE π
It returns a pointer to the created bitmap, or NULL if the bitmap could not be created. so like, always check for NULL, bestie, don't just rawdog it π
and remember to free this bitmap later to avoid memory leaks! your future self will thank you. lowkey highkey the most important sentence on this page. π
π¦ SEE ALSO π¦
create_bitmap_ex(3alleg4)create_sub_bitmap(3alleg4)create_video_bitmap(3alleg4)create_system_bitmap(3alleg4)destroy_bitmap(3alleg4)set_color_depth(3alleg4)is_memory_bitmap(3alleg4)clear_bitmap(3alleg4)clear_to_color(3alleg4)
and that's the whole page, bestie!! π this was Allegro version 4.4.3, and the page itself is create_bitmap(3alleg4) β go forth and allocate responsibly, 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