Thread: RGBImage Issues
View Single Post
  #4   Spotlight this post!  
Unread 27-01-2013, 00:00
mikets's Avatar
mikets mikets is offline
Software Engineer
FRC #0492 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Bellevue, WA
Posts: 667
mikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of lightmikets is a glorious beacon of light
Re: RGBImage Issues

Quote:
Originally Posted by bob.wolff68 View Post
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.
__________________
Reply With Quote