create_bitmap(3)

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

πŸ’– create_bitmap(3) β€” the Allegro manual, but make it cute πŸ’–

okay bestie, welcome to the Allegro manual πŸŽ€ yes THE Allegro, the game programming library, and yes this is the page for create_bitmap(3) and it is lowkey iconic. grab a snack, we're making bitmaps ✨


🌸 NAME 🌸

create_bitmap β€” creates a memory bitmap. Allegro game programming library. that's the whole vibe, that's the job πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

BITMAP *create_bitmap(int width, int height);

✨ DESCRIPTION ✨

so the way that this works is: it creates a memory bitmap sized width by height. boom. that's the whole thing 🫢

and like, the details matter here, so listen up:

  • clipping is turned on for this new bitmap, and the clipping rectangle is set to the full size of the bitmap. full send, no cropping, it's giving full canvas energy 🌈
  • the image memory is not cleared. so it's probably gonna contain garbage 😭 no cap. you should clear the bitmap before using it, fr fr.
  • this routine always uses the global pixel format, as specified by calling set_color_depth(). it's not out here doing its own thing, it follows the global setting periodt πŸ’…

and the rules, bestie, the rules:

  • the minimum height of the BITMAP must be 1
  • width can't be negative
⭐ write that down. height 1 minimum, width never negative. them's the rules.

Example, because a visual is everything πŸ’–:

/* 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);

see how it creates, checks, uses, then destroys? main character energy honestly πŸ‘‘


πŸ’œ RETURN VALUE πŸ’œ

returns a pointer to the created bitmap πŸŽ€ or NULL if the bitmap could not be created 😭 (and if you get NULL, do NOT just keep going, handle it, bestie).

remember to free this bitmap later to avoid memory leaks. that's not optional, that's self care ✨


πŸŽ€ SEE ALSO πŸŽ€

go read these next, they're all in the family 🫢


and that's the page πŸ’… this was the Allegro manual, version 4.4.3, and you just read create_bitmap(3) β€” go make something gorgeous with it, ily, bye bestie πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from