al_create_sub_bitmap(3alleg5)
β¨ NAME β¨
al_create_sub_bitmap β the Allegro 5 API glow-up where you carve a lil baby bitmap out of a bigger one π (this page lives in the Allegro 5 manual, bestie)
πΈ SYNOPSIS πΈ
#include <allegro5/allegro.h>
ALLEGRO_BITMAP *al_create_sub_bitmap(ALLEGRO_BITMAP *parent,
int x, int y, int w, int h)
π¦ DESCRIPTION π¦
okay so basically: this makes a sub-bitmap of the parent, sitting at the coordinates you give it and sized however you want. And what even IS a sub-bitmap? It's a bitmap that shares drawing memory with a bitmap that already existed (the parent π) β but it can have a totally different size and different clipping settings. same pixels, new vibe. it's giving remix.
Also, heads up: the sub-bitmap is allowed to originate off the parent bitmap or extend past it. boundaries? never heard of her.
There's a whole discussion about using sub-bitmaps of the backbuffer over in al_get_backbuffer(3alleg5) β go read it, it's important iykyk.
The parent bitmap's clipping rectangles? ignored. completely. the parent does not get a say.
If a sub-bitmap was not created, or just like, cannot be created, then NULL comes back. that's your sign it didn't work π
When you're done with the sub-bitmap you must call al_destroy_bitmap(3alleg5) on it to free up any resources allocated for it. yes really. do it. π«Ά
β οΈ okay this part matters so listen up: destroying the parents of sub-bitmaps will not destroy the sub-bitmaps. instead, the sub-bitmaps become invalid and you should no longer use them for drawing β but they still must be destroyed with al_destroy_bitmap(3alleg5) anyway. rude, i know. aside from that, it does not matter whether you destroy a sub-bitmap before or after its parent. either order, no drama.
π SEE ALSO π
that's the whole page, bestie β go forth and sub-bitmap responsibly πβ¨ this was pulled straight from the Allegro reference manual, filed under al_create_sub_bitmap(3alleg5) π
slay π¦
π¦ 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