I need to get hold of the width and height values from the bmp so that I can pass those as arguments when I later create a gdk pixmap from the raw pixeldata in the bitmap. I did some research on the BMP-format and the file header should look like this:
struct Fileheader
{
unsigned short Type; // signature - 'BM'
unsigned long Size; // file size in bytes
unsigned short Reserved1; // 0
unsigned short Reserved2; // 0
unsigned long OffBits; // offset to bitmap
unsigned long StructSize; // size of this struct (40)
unsigned long Width; // bmap width in pixels
unsigned long Height; // bmap height in pixels
unsigned short Planes; // num planes - always 1
unsigned short BitCount; // bits per pixel
unsigned long Compression; // compression flag
unsigned long SizeImage; // image size in bytes
long XPelsPerMeter; // horz resolution
long YPelsPerMeter; // vert resolution
unsigned long ClrUsed; // 0 -> color table size
unsigned long ClrImportant; // important color count
Fileheader()
{
Size=Width=Height=Planes=BitCount=Compression=SizeImage=XPelsPerMeter= YPelsPerMeter=ClrUsed=ClrImportant=Type=StructSize=Reserved1=Reserved2=OffBits=0;}
};
}
after fetching the blob the standard way into row[0]
Fileheader fh;
memcpy(&fh, row[0], sizeof(Fileheader));
will give just gibberish values when
cout << "width: " << fh.Width << ", height: " << fh.Height << endl;
namely: width: 65536, height: 5626121834492592128
Anyone see what's wrong here? I'm on a 64-bit linux box BTW.