Quote:
Originally Posted by bob.wolff68
If you're feeling confident that all this makes sense so far, I would suggest that you try doing a little test to ensure that the file is really "there" by opening the file and reading the first 4 bytes of the file or something...
Code:
FILE* fp = fopen("testPattern.jpg", "rb");
if (fp) {
unsigned char test[10];
int read;
read = fread(test, 1, 4, fp);
if (read != 4) {
printf("Did not read 4 bytes. Error.\n");
}
else {
printf("SUCCESS. File at least exists.\n");
}
}
else {
printf("File not found.\n");
}
|
BTW, if you read and display the first 16 bytes instead of the first 4 bytes, you will see a 4-byte signature at offset 6 that will tell you if the file is a JPG or not. I believe JPG files have something like "Exif" or "JFIF" at offset 6 whereas BMP files have "BM" as the first 2 bytes of the file. There may be some other valid signatures, but you get a pretty good idea on what format the file is.