save_bitmap(3)

πŸ“¦ version 4.4.3.1, in fedora 43, fedora 44

✨ save_bitmap(3) ✨

okay bestie, welcome to the Allegro manual πŸ’– this one's called save_bitmap, and fr fr it's the glow-up moment where your bitmap leaves the computer and becomes an actual file πŸŽ€


🌸 NAME 🌸

save_bitmap β€” Saves a bitmap into any supported file format. Allegro game programming library. periodt πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

#include <allegro.h>

int save_bitmap(const char *filename, BITMAP *bmp, const RGB *pal);

πŸ’œ DESCRIPTION πŸ’œ

So like, the whole vibe here is: this function writes a bitmap into a file, using the palette you hand it, and that palette should be an array of 256 RGB structures. no cap. 🫢

The output format? it's giving detective work, because it gets determined from the filename extension. at present this function supports BMP, PCX and TGA formats. slay ✨

okay now the part where I gotta be your responsible bestie, because there are two things to watch out for:

  • on some video cards it may be faster to copy the screen to a memory bitmap and save the latter 🧚
  • and if you use this to dump the screen into a file, you may end up with an image much larger than you were expecting 😭 because Allegro often creates virtual screens larger than the visible screen. ikyky

the way you get around that? use a sub-bitmap to specify which part of the screen to save, eg:

BITMAP *bmp;
PALETTE pal;
...
get_palette(pal);
bmp = create_sub_bitmap(screen, 0, 0, SCREEN_W, SCREEN_H);
save_bitmap("dump.pcx", bmp, pal);
destroy_bitmap(bmp);

look at her go, main character energy πŸ‘‘


⭐ RETURN VALUE ⭐

Returns non-zero on error. (yes queen, zero means you ate, non-zero means the vibe check failed πŸ’€)


🌈 SEE ALSO 🌈


and that's the whole page, bestie πŸŽ€ this came to you from the Allegro manual, version 4.4.3, and the page itself is save_bitmap(3) β€” go save something iconic πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from