for (i = 0; i < w * h; i++) {
if (!fread(&value, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
+ fclose(f);
return NULL;
}
image->comps[compno].data[i] = raw_cp->rawSigned?(char)value:value;
unsigned char temp;
if (!fread(&temp, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
+ fclose(f);
return NULL;
}
value = temp << 8;
if (!fread(&temp, 1, 1, f)) {
fprintf(stderr,"Error reading raw file. End of file probably reached.\n");
+ fclose(f);
return NULL;
}
value += temp;
}
else {
fprintf(stderr,"OpenJPEG cannot encode raw components with bit depth higher than 16 bits.\n");
+ fclose(f);
return NULL;
}