I'm reading header info from a bitmap. I can get the image width and bit-depth fine but the height comes out as -16. I am almost certain that this problem is caused by me reading bytes from the file as char type, but I cant work out how to get it to read as Uint8. Aslo the way I am doing this is probably unnecessarily complicated. Heres my code:
Any suggestions on a working/better way to read this data?Code:int Image::LoadBMP(char* filename) { ifstream in; in.open(filename, ios::binary); if(! in.is_open()) return LOAD_IMAGE_INVALID; char i[4]; in.seekg(18, ios::beg); in.read(i, 4); w=(i[3]<<24)+(i[2]<<16)+(i[1]<<8)+i[0]; //in.seekg(22, ios::beg); in.read(i, 4); h=(i[3]<<24)+(i[2]<<16)+(i[1]<<8)+i[0]; in.seekg(2, ios::cur); in.read(i, 2); bpp=(i[1]<<8)+i[0]; in.close(); return IMAGE_LOAD_SUCCESS; }