create_sub_bitmap(3)
π create_sub_bitmap(3) π
okay bestie, welcome to the Allegro manual β yes, that Allegro, the game programming library, and today we're talking about the one and only create_sub_bitmap(3). pull up a chair, grab a strawberry π, and let's get into it.
β¨ NAME β¨
create_sub_bitmap β creates a memory sub bitmap. Allegro game programming library. π
π¦ SYNOPSIS π¦
#include <allegro.h>
BITMAP *create_sub_bitmap(BITMAP *parent, int x, y, width, height);
like yes, that's the whole vibe. she's short, she's sweet, she takes five arguments and gives you back a whole bitmap. π
πΈ DESCRIPTION πΈ
okay so, create_sub_bitmap creates a sub-bitmap. and what even is a sub-bitmap, you ask? it's a bitmap that shares drawing memory with a bitmap that already exists β the parent β but it can have a totally different size and different clipping settings. it's giving "same soul, different outfit." π
one thing you GOTTA know, and I mean this with my whole chest: when you're creating a sub-bitmap of the mode-X screen, the x position has to be a multiple of four. no cap. four, eight, twelve, sixteen β those are your girls. anything else and it's not happening.
also! the sub-bitmap's width and height are allowed to extend past the right and bottom edges of the parent β they'll just get clipped, nbd, that's fine, we move. BUT. π¨ the origin point has to lie within the parent region. that part is non-negotiable, bestie. origin outside the parent = not the move.
π RETURN VALUE π
you get back a pointer to the freshly created sub bitmap. yay! π
or... you get NULL if the sub bitmap could not be created. π it happens. it's not you, it's the memory.
and now the part where I need you to lock in, because this one's important and I'm not being dramatic:
free the sub bitmap BEFORE you free the parent bitmap. do not skip this. seriously. if you don't, you're looking at memory leaks and potential crashes from accessing memory that's already been freed. that's the bad kind of chaos. π
π«Ά SEE ALSO π«Ά
the whole friend group, assembled:
create_bitmap(3)create_bitmap_ex(3)destroy_bitmap(3)is_sub_bitmap(3)clear_bitmap(3)clear_to_color(3)expat(3)exscroll(3)exswitch(3)
and that's the page, babe. this was the Allegro manual, version 4.4.3, and you read create_sub_bitmap(3) all the way to the end β which honestly? iconic. go free your sub bitmaps before your parents, hydrate, and slay. πβ¨π¦
π¦ where this page comes from
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 43: allegro-devel 4.4.3.1-18.fc43 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- fedora 44: allegro-devel 4.4.3.1-20.fc44 Β· Giftware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms