I'm trying to load a BMP in Linux using the Windows structures. It's loading, but a lot of the values are just junk. First, heres the code:
bmfh.bfType will give me 19778, like it's supposed to. bfOffBits returns a good value too, I think. As for most of the other values, then seem bad. Here's some examples:Code:#include <iostream> #include <cstdio> #define BYTE unsigned char #define DWORD unsigned int #define LONG int #define UINT unsigned int #define WORD unsigned short int #define LPSTR char* typedef struct tagBITMAPFILEHEADER { WORD bfType; DWORD bfSize; WORD bfReserved1; WORD bfReserved2; DWORD bfOffBits; } BITMAPFILEHEADER, *PBITMAPFILEHEADER; typedef struct tagBITMAPINFOHEADER{ DWORD biSize; LONG biWidth; LONG biHeight; WORD biPlanes; WORD biBitCount; DWORD biCompression; DWORD biSizeImage; LONG biXPelsPerMeter; LONG biYPelsPerMeter; DWORD biClrUsed; DWORD biClrImportant; } BITMAPINFOHEADER, *PBITMAPINFOHEADER; typedef struct tagRGBQUAD { BYTE rgbBlue; BYTE rgbGreen; BYTE rgbRed; BYTE rgbReserved; } RGBQUAD; void loadBMP(LPSTR filename, BITMAPFILEHEADER *tbmfh, BITMAPINFOHEADER *tbmih) { FILE *in; in=fopen(filename,"rb"); fread(tbmfh,sizeof(BITMAPFILEHEADER),1,in); fread(tbmih,sizeof(BITMAPINFOHEADER),1,in); return; } int main() { BITMAPFILEHEADER bmfh; BITMAPINFOHEADER bmih; loadBMP("/home/david/DavidsStuff/Pictures/somebmp.bmp", &bmfh, &bmih); if(bmih.biBitCount != 24) std::cout << bmih.biSize << std::endl; std::cin.get(); }
biBitCount: 0 (Should be 1, 4, 8, or 14)
biWidth: 39976960
biSize: 44892160 (Should be 40)
biCompression: 5588251136
This article explains what the values are: http://www.gamedev.net/reference/art...rticle1966.asp
The rest are more of the same. I also get similar results with different bmp's. Any clue why?
Thanks,
David



LinkBack URL
About LinkBacks


