Fix jpeg loading

This commit is contained in:
Kwabena W. Agyeman 2021-12-28 19:04:38 -08:00
parent e20b1b787f
commit 165408f3c8
2 changed files with 9 additions and 5 deletions

View File

@ -564,10 +564,14 @@ bool imlib_read_geometry(FIL *fp, image_t *img, const char *path, img_read_setti
file_read_open(fp, path);
file_buffer_on(fp); // REMEMBER TO TURN THIS OFF LATER!
vflipped = bmp_read_geometry(fp, img, path, &rs->bmp_rs);
} else {
} else if ((magic[0]==0xFF) && (magic[1]==0xD8)) { // JPG
rs->format = FORMAT_JPG;
file_read_open(fp, path);
// Do not use file_buffer_on() here.
jpeg_read_geometry(fp, img, path, &rs->jpg_rs);
file_buffer_on(fp); // REMEMBER TO TURN THIS OFF LATER!
} else {
ff_unsupported_format(NULL);
}
imblib_parse_extension(img, path); // Enforce extension!
return vflipped;

View File

@ -2100,14 +2100,14 @@ void jpeg_read_geometry(FIL *fp, image_t *img, const char *path, jpg_read_settin
|| ((0xFFCD <= header) && (header <= 0xFFCF)))
{
read_byte_ignore(fp);
uint16_t width;
read_word(fp, &width);
width = __REV16(width);
uint16_t height;
read_word(fp, &height);
height = __REV16(height);
uint16_t width;
read_word(fp, &width);
width = __REV16(width);
rs->jpg_w = width;
rs->jpg_h = height;
rs->jpg_size = IMLIB_IMAGE_MAX_SIZE(f_size(fp));