al_register_bitmap_identifier(3alleg5)

πŸ“¦
version 5.2.11.3 Β· 4 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– al_register_bitmap_identifier β€” Allegro 5 API πŸ’–

okay bestie, so this one is from the Allegro 5 API (that's the 3alleg5 manual, iykyk) and it's literally the ✨ registration desk ✨ for bitmap detection. 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 what you're doing here is registering an identify handler for al_identify_bitmap(3alleg5). 🫢

The function you pass in gets used to sniff out files that belong to the given extension. It'll be called with a single argument of type ALLEGRO_FILE(3alleg5) β€” that's a file handle, opened for reading, sitting right at the first byte of the file. πŸ‘‘

And here's the vibe check for your handler: try to read as few bytes as possible to safely figure out whether the file contents match the type with that extension. If yes β†’ return true. If no β†’ return false. that's it, that's the whole job πŸ’…

⚠️ important!! the file handle must not be closed. but also β€” plot twist β€” you don't need to reset it back to the beginning either. so like, no pressure on the cleanup, just don't commit the crime of closing it πŸ™ˆ

The extension should include the leading dot (.) character. fr fr, don't forget the dot. And it gets matched case-insensitively ✨

Also!! the identifier argument may be NULL β€” and that's how you unregister an entry. bye bestie πŸ‘‹

Returns true on success, false on error. And yes, it returns false if you're trying to unregister an entry that doesn't even exist. 😭 (rip, nothing to remove)


✨ SINCE ✨

5.1.12 β€” been iconic since then πŸ’–


✨ SEE ALSO ✨


and that's the whole page, bestie!! πŸŽ€ source is the Allegro reference manual and this lil entry lives under the al_register_bitmap_identifier(3alleg5) name. go forth and detect bitmaps responsibly, mwah πŸ’…βœ¨πŸ’–

πŸ“¦ where this page comes from