I copied this code from the libjpeg example and im passing it standard files;
FILE *soureFile;
if ((soureFile = fopen(sourceFilename, "rb")) == NULL)
{
fprintf(stderr, "can't open %s\n", sourceFilename);
exit(1);
}
jpeg_stdio_src(&jpegDecompress, soureFile);
jpeg_read_header(&jpegDecompress, true);
It results in a file pointer that contains no information and therefore breaks on the last line with access violations.
Any ideas?
EDIT: On Tobias’ advice the fopen does appear to open the file ok but the jpeg_read_header is in turn failing with the access violation still.
EDIT: After a little more digging
JPEG support with ijg – getting access violation
“
selectisn’t broken“.If
fopenreturned a valid file pointer, andjpeg_read_headercan’t use it, someone between those two statements has done something bad to it.The only one in between is the
jpg_stdio_srccall, which wouldn’t fail if all it’s preconditions are fulfilled.Bottom line: see why
jpg_stdio_srcfails. My guess: it needs to be constructed using thejpeg_create_decompressmacro.