//simplified example to get RGBs out of a BMP file.

unsigned int padding = 4 - ((numCols * 3) % 4);//bmps can have a few bytes of padding at end of each row
if (padding == 4) padding = 0;

ifstream fin;
fin.open(filename.c_str());
fin.ignore(54); //skip header

char* imageptr;
imageptr = new char[numRows * (numCols*3 + padding)]; //file size - 54

fin.read(imageptr, (numRows * (numCols*3+padding)));

for (int i = 0; i < numRows*(numCols*3+padding); ++i) cout << (int) imageptr[i] << " ";



This is a simplified version of my code to demonstrate the problem (I'm using unsigned chars of course and skipping over the padding at the end of the rows). so basically the cout at the end should be spamming me with all different sorts of values between -127 and 127, but instead I'm getting only -51, with a few groupings of 0's here and there. How could this be?

So basically what happens when I read in information like this from an image, and use it write another bmp file, I get a picture with the exact same dimensions as the original, only its all grey with a few black specks here and there. (I think -51 is 205 or something unsigned). I don't understand how I can read a file and get the same character values over and over when they should be changing dramatically.