al_get_parent_bitmap(3alleg5)
β¨ NAME β¨
al_get_parent_bitmap β the Allegro 5 API function that finds your bitmap's β¨actualβ¨ parent, no cap π
π SYNOPSIS π
#include <allegro5/allegro.h>
ALLEGRO_BITMAP *al_get_parent_bitmap(ALLEGRO_BITMAP *bitmap)
π¦ DESCRIPTION π¦
okay so bestie, listen π β you hand it a bitmap, and it gives you back the bitmap that this bitmap is a sub-bitmap of. That's it. That's the whole vibe.
- If your bitmap is not a sub-bitmap? You get
NULL. Simple. π - This function always returns the real bitmap, and never a sub-bitmap. lowkey the most important thing here.
π¨ and this is the part that gets people: what you get back might NOT match what was passed to al_create_sub_bitmap(3alleg5). fr fr. don't assume.
Consider this code, for instance:
ALLEGRO_BITMAP* a = al_create_bitmap(512, 512);
ALLEGRO_BITMAP* b = al_create_sub_bitmap(a, 128, 128, 256, 256);
ALLEGRO_BITMAP* c = al_create_sub_bitmap(b, 64, 64, 128, 128);
ASSERT(al_get_parent_bitmap(b) == a && al_get_parent_bitmap(c) == a);
so b is a sub-bitmap of a, and c is a sub-bitmap of bβ¦ but look at that assertion π it says al_get_parent_bitmap(c) == a, NOT == b. And the assertion will pass! π
Why? Because only a is a real bitmap, and both b and c are its sub-bitmaps. The way the chain just collapses back to the original real one β it's giving generational parent energy ππ
So like. b's parent is a. c's parent is also a. Periodt. π
πΈ SINCE πΈ
5.0.6, 5.1.2 β she's been iconic for a minute π«Ά
β SEE ALSO β
and that's the whole page bestie!! this one's from the Allegro reference manual, covering al_get_parent_bitmap(3alleg5) π go forth and parent-check your bitmaps responsibly π§β¨
π¦ where this page comes from
- debian trixie: allegro5-doc 2:5.2.10.1+dfsg-1 Β· Zlib
- ubuntu questing: allegro5-doc 2:5.2.10.1+dfsg-1build1
- ubuntu resolute: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- ubuntu stonking: allegro5-doc 2:5.2.11.3+dfsg-1 Β· Zlib
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms