Hi all,
I need to read the color code from an image file. (The code for each pixel.) I am trying it with this simple code, but I get to read the header first. How do I know where the header ends and the body begins?
I can change the file format (to gif, tif, bmp, etc...anything) This is a simple OCR project, and the images are in Black and White.
My code is:
#include <fstream.h>
void main()
{
fstream File("2.jpg",ios:
ut | ios::in | ios::binary);
char ch;
File.seekg(ios::beg); //go to the file beginning
for(int i=0; i < 11; i++){
File.get(ch); //read one character
cout << ch << " - " <<(int)ch <<endl; //display it
}
File.close();
}
I need to read the color code from an image file. (The code for each pixel.) I am trying it with this simple code, but I get to read the header first. How do I know where the header ends and the body begins?
I can change the file format (to gif, tif, bmp, etc...anything) This is a simple OCR project, and the images are in Black and White.
My code is:
#include <fstream.h>
void main()
{
fstream File("2.jpg",ios:
char ch;
File.seekg(ios::beg); //go to the file beginning
for(int i=0; i < 11; i++){
File.get(ch); //read one character
cout << ch << " - " <<(int)ch <<endl; //display it
}
File.close();
}