Original Post
Reading a 8bit grayscale image is easy:
You have an array of width*height unsigned chars and read them in.
( fread( chars, sizeof(char), 1, file )
Yesterday I tried to do the same with a 16bit grayscale image but failed. I thought I culd just replace
the unsigned char with an unsigned int. Here''s the code for reading a 3 pixel image:
But the result of this is not 65535, 32768 and 0 (Pixels were white, gray, black), but 2.15587e+009, 0 and 0. Really strange values!!!
Can anyone give me a hint on what I''m doing wrong?
FILE* mf = fopen("3pixels.raw","rb");
unsigned int number1 = 0;
unsigned int number2 = 0;
unsigned int number3 = 0;
fread( &number1, sizeof(unsigned int), 1, mf );
fread( &number2, sizeof(unsigned int), 1, mf );
fread( &number3, sizeof(unsigned int), 1, mf );
fclose(mf);