create_sub_bitmap(3alleg4)

✨ NAME ✨

create_sub_bitmap β€” bestie, it literally creates a memory sub bitmap πŸ’…. Part of the Allegro game programming library, no cap. πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

BITMAP *create_sub_bitmap(BITMAP *parent, int x, y, width, height);

🌸 DESCRIPTION 🌸

Okay so picture this: you've got a bitmap already, right? A whole entire parent bitmap, living its main character life. Now create_sub_bitmap makes you a sub-bitmap β€” which is a bitmap that shares its drawing memory with that pre-existing bitmap, but it can have its own different size and its own clipping settings. It's giving "we're not copies, we're connected." 🫢

Tiny but crucial detail: when you're making a sub-bitmap of the mode-X screen, the x position must be a multiple of four. Like, that's not a suggestion, that's the vibe check. πŸ”₯

The sub-bitmap's width and height can totally extend past the right and bottom edges of the parent β€” they'll just get clipped, nbd πŸ™ˆ. But the origin point has to lie inside the parent region. That part is non-negotiable, bestie. πŸ‘‘


πŸ’– RETURN VALUE πŸ’–

It hands you back a pointer to the freshly created sub bitmap, all sparkly and new ✨. Or, if the sub bitmap couldn't be created, you get NULL β€” and honestly? Not iconic, but it happens. 😭

⚠️ GIRL, LISTEN ⚠️ Remember to free the sub bitmap before you free the parent bitmap! Otherwise you get memory leaks and potentially crashes from accessing memory that's already been freed. That's not a fun surprise, that's a jumpscare. πŸ’€

⭐ SEE ALSO ⭐


Okay that's the whole page, you ate that πŸ“ β€” this was Allegro, version 4.4.3, and yes, the page is literally named create_sub_bitmap(3alleg4). Go forth and make sub-bitmaps, queen. πŸ’œπŸ§š