struct jpeg_source_mgr mgr;
FILE*fi = fopen(filename, "rb");
- if(!fi)
+ if(!fi) {
+ fprintf(stderr, "Couldn't open file %s\n", filename);
return 0;
- fseek(fi, SEEK_END, 0);
- long filesize = ftell(fi);
- fseek(fi, SEEK_SET, 0);
- fclose(fi);
+ }
cinfo.err = jpeg_std_error(&jerr);
jpeg_create_decompress(&cinfo);
for (y=0;y<height;y++) {
int x;
U8 *js = scanline;
- RGBA*line = (RGBA*)&(*dest)[y*width];
+ RGBA*line = &((RGBA*)(*dest))[y*width];
jpeg_read_scanlines(&cinfo, &js, 1);
if (cinfo.out_color_space == JCS_GRAYSCALE) {