save_bitmap(3alleg4)
β¨ NAME β¨
save_bitmap(3alleg4) is the Allegro game programming library page for save_bitmap β and bestie, it does exactly what it says: Saves a bitmap into any supported file format. πΎβ¨
π¦ SYNOPSIS π¦
#include <allegro.h>
int save_bitmap(const char *filename, BITMAP *bmp, const RGB *pal);
π DESCRIPTION π
Okay so save_bitmap writes a bitmap into a file, using the palette you hand it. That palette should be an array of 256 RGB structures. The output format is determined from the filename extension: at present this function supports BMP, PCX and TGA formats. No cap. π
Two things to watch out for, bestie β not me trying to scare you, just keeping it real:
- On some video cards it may be faster to copy the screen to a memory bitmap and save the latter. π
- 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. π
You can get around this by using 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);
π«Ά RETURN VALUE π«Ά
Returns non-zero on error. That's the vibe check, fr fr. π₯
π SEE ALSO π
save_bmp(3alleg4)save_pcx(3alleg4)save_tga(3alleg4)load_bitmap(3alleg4)register_bitmap_file_type(3alleg4)
Allegro manual, version 4.4.3, page save_bitmap(3alleg4) β the footer didn't list a date, so no fake date from me, bestie. Keeping it mysterious and iconic. π π¦β¨
π¦ where this page comes from
- debian bookworm: allegro4-doc 2:4.4.3.1-3 Β· Allegro-gift-ware
- debian trixie: allegro4-doc 2:4.4.3.1-5 Β· Allegro-gift-ware
- ubuntu jammy: allegro4-doc 2:4.4.3.1-2 Β· Allegro-gift-ware
- ubuntu noble: allegro4-doc 2:4.4.3.1-4.1build3 Β· Allegro-gift-ware
- ubuntu questing: allegro4-doc 2:4.4.3.1-6
- ubuntu resolute: allegro4-doc 2:4.4.3.1-7 Β· Allegro-gift-ware
- ubuntu stonking: allegro4-doc 2:4.4.3.1-9 Β· Allegro-gift-ware
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms