Go to Post Dave's grammar is broken. - Madison [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:06.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi