Files
allegro_qoi/sample.c

31 lines
951 B
C
Raw Normal View History

2025-09-07 23:14:37 -04:00
// This program simply loads a QOI file into Allegro
// as a texture and then dumps the texture data as a PNG.
2025-09-07 22:40:06 -05:00
// Take notice of lines 26 and 27. You only need to initialize
2025-09-07 23:14:37 -04:00
// the QOI plugin (this registers the function hooks that Allegro
// will use whenever you want to I/O on a filename ending in .qoi)
//
2025-09-07 22:40:06 -05:00
// Compile the sample program with:
// gcc -o sample allegro_qoi.c sample.c -lallegro -lallegro_image -I./
// Then run it with a QOI image as the first argument.
2025-09-07 23:14:37 -04:00
//
// qoi.h should be inside of your include path.
// Either place it here, or in your system's global includes.
2025-09-07 22:40:06 -05:00
#include <stdio.h>
2025-09-07 23:14:37 -04:00
#include <allegro5/allegro.h>
#include <allegro5/allegro_image.h>
#include "allegro_qoi.h"
2025-09-07 22:40:06 -05:00
int main(int argc, char **argv) {
if (argc < 2) {
printf("Usage: sample <filename>\n");
return 0;
}
2025-09-07 23:14:37 -04:00
al_init();
al_init_image_addon();
al_init_qoi();
2025-09-07 22:40:06 -05:00
ALLEGRO_BITMAP* bmp = al_load_bitmap(argv[1]);
2025-09-07 23:14:37 -04:00
al_save_bitmap("out.png", bmp);
return 0;
}