AL_REGISTER_BITMAP_IDENTIFIER(3)

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

πŸ’… al_register_bitmap_identifier β€” Allegro 5 API πŸŽ€

ok so this page lives in the Library Functions Manual section of the Allegro docs, and bestie, it's short but it matters. Let's get into it ✨


✨ NAME ✨

al_register_bitmap_identifier β€” Allegro 5 API πŸ¦‹


🌸 SYNOPSIS 🌸

#include <allegro5/allegro.h>

bool al_register_bitmap_identifier(const char *extension,
   bool (*identifier)(ALLEGRO_FILE *f))

πŸ’– DESCRIPTION πŸ’–

So here's the vibe: you're registering an identify handler for al_identify_bitmap(3). Basically you hand over a function, and that function gets used to detect files for whatever extension you named. Iconic little tag-team situation 🀝

Your handler gets called with a single argument of type ALLEGRO_FILE(3) β€” that's a file handle, already opened for reading, sitting right at the first byte of the file. Ready to go, no setup needed πŸ’…

Now, the handler's whole job is a vibe check: it should try to read as few bytes as possible to safely determine whether the file contents actually correspond to the type with that extension. If yes β†’ return true. If no β†’ return false. That's it, that's the job 🫢

⚠️ Important caveats, no cap: the file handle must not be closed by your handler. You also don't need to reset it back to the beginning β€” so like, don't stress about rewinding, just don't close it either 😭

A couple more deets about the arguments:

  • The extension should include the leading dot (.) character. And good news β€” it gets matched case-insensitively πŸ‘‘
  • The identifier argument can be NULL if you want to unregister an entry. Ghosting it, essentially πŸ™ˆ

Return value time: true on success, false on error. Also β€” and this is the little gotcha β€” it returns false if you try to unregister an entry that doesn't exist 🧚


⭐ SINCE ⭐

5.1.12 β€” been here since the old days, fr fr πŸ’œ


🌈 SEE ALSO 🌈


okay that's the whole page! this little beauty comes straight out of the Allegro reference manual, so shoutout to the Allegro gang for keeping al_register_bitmap_identifier(3) documented and slaying πŸ’–βœ¨ go forth and identify those bitmaps bestie πŸ¦‹πŸ’…

πŸ“¦ 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