1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include "allegro5/allegro.h"
#include "allegro5/allegro_image.h"
#include "allegro5/internal/aintern_image.h"
bool _al_identify_png(ALLEGRO_FILE *f)
{
uint8_t x[8];
al_fread(f, x, 8);
if (memcmp(x, "\x89PNG\r\n\x1a\n", 8) != 0)
return false;
return true;
}
bool _al_identify_jpg(ALLEGRO_FILE *f)
{
uint8_t x[4];
uint16_t y;
y = al_fread16be(f);
if (y != 0xffd8)
return false;
al_fseek(f, 6 - 2, ALLEGRO_SEEK_CUR);
al_fread(f, x, 4);
if (memcmp(x, "JFIF", 4) != 0)
return false;
return true;
}
bool _al_identify_webp(ALLEGRO_FILE *f)
{
uint8_t x[4];
al_fread(f, x, 4);
if (memcmp(x, "RIFF", 4) != 0)
return false;
al_fseek(f, 4, ALLEGRO_SEEK_CUR);
al_fread(f, x, 4);
if (memcmp(x, "WEBP", 4) != 0)
return false;
return true;
}
|