al_create_sub_bitmap(3)

πŸ“¦
version 5.2.11.3 Β· 3 versions
, in arch rolling

πŸ’– NAME πŸ’–

okay so this is the al_create_sub_bitmap(3) page from the Library Functions Manual, and the function is al_create_sub_bitmap β€” Allegro 5 API energy, no cap. πŸ’…βœ¨

🌸 SYNOPSIS 🌸

bestie, here’s the exact spell to cast:

#include <allegro5/allegro.h>

ALLEGRO_BITMAP *al_create_sub_bitmap(ALLEGRO_BITMAP *parent,
   int x, int y, int w, int h)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so al_create_sub_bitmap creates a sub-bitmap of the parent, at the coordinates you specify and with the size you specify. It’s giving β€œbaby bitmap, same drawing memory” β€” a sub-bitmap is a bitmap that shares drawing memory with a pre-existing parent bitmap, but it can possibly have a different size and clipping settings. πŸ‘‘

  • The sub-bitmap may originate off or extend past the parent bitmap. yes, it can be extra like that. πŸ’…
  • go read the discussion in al_get_backbuffer(3) about using sub-bitmaps of the backbuffer, iykyk.
  • the parent bitmap’s clipping rectangles are ignored. not invited to the group chat. 🚫

If a sub-bitmap was not or cannot be created, then NULL is returned. that’s the vibe check failing, bestie. 😭

When you’re done using the sub-bitmap, you must call al_destroy_bitmap(3) on it to free any resources allocated for it. no ghosting your cleanup duties, periodt. 🧹✨

⚠️ big note, bestie: destroying parents of sub-bitmaps will not destroy the sub-bitmaps. instead, the sub-bitmaps become invalid and should no longer be used for drawing β€” they still must be destroyed with al_destroy_bitmap(3) however. it does not matter whether you destroy a sub-bitmap before or after its parent otherwise. so like… destroy responsibly, okay? πŸ’€πŸ«Ά

✨ SEE ALSO ✨

you’ll also wanna peek at al_create_bitmap(3) β€” it’s the related icon, fr fr. 🌈


cute sign-off: this page is signed by the Allegro reference manual, with al_create_sub_bitmap(3) riding alongside β€” bye bestie, go make some sub-bitmaps! πŸ’–πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from
  • arch rolling: allegro 5.2.11.3-2 Β· Zlib AND BSD-3-Clause AND OFL-1.1 AND LicenseRef-Custom
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms