register_..._file_type(3alleg4)

πŸ’– register_..._file_type β€” Allegro manual edition πŸ’–

okay bestie, welcome to the Allegro manual, the 3alleg4 chapter specifically, and today's main character is a lil function that lets you teach Allegro brand new image formats. yes fr fr, you can just... add your own. iconic.


✨ NAME ✨

register_bitmap_file_type β€” registers custom bitmap loading/saving functions. it's giving "Allegro game programming library" energy, no cap.


🌸 SYNOPSIS 🌸

#include <allegro.h>

void register_bitmap_file_type(const char *ext, BITMAP *(*load)(const
char *filename, RGB *pal), int (*save)(const char *filename, BITMAP
*bmp, const RGB *pal));

πŸ¦‹ DESCRIPTION πŸ¦‹

so the whole vibe here is: you're sliding a brand new file type into load_bitmap() and save_bitmap()'s DMs, and you're bringing along the routines that actually read and write images in that format. you supply both a reader and a writer, and either one of those function pointers can be NULL if you don't feel like providing it 🫢 (yes, NULL is valid, she's flexible like that).

the functions you hand over must follow the same prototype as load_bitmap() and save_bitmap(). no improvising, bestie, the signature is the signature.

example, because we love a demonstration:

BITMAP *load_dump(const char *filename, RGB *pal)
{
   ...
}

int save_dump(const char *filename, BITMAP *bmp, const RGB *pal)
{
   ...
}

   register_bitmap_file_type("dump", load_dump, save_dump);

look at her go πŸŽ€ you defined load_dump and save_dump, and now "dump" is a whole registered file type. slay.


πŸ‘‘ SEE ALSO πŸ‘‘


lowkey the most important thing: this is the Allegro manual, 3alleg4 section, and the page header names it as register_..._file_type(3alleg4) β€” that's the family of register-a-file-type functions, and this is the bitmap one πŸ’…

and that's a wrap, bestie! this page was brought to you by Allegro, version 4.4.3 β€” she's the source, she's the version, and the footer said so on the same line as register_..._file_type(3alleg4). periodt. πŸ’–βœ¨πŸŒˆ