Original Post
hello,
I copied Andre Lamothe''s routine (Tricks of the p.346) to read a bitmap but changed the way the file is read a little (used fread/fseek instead of _lread/ _seek ).
I get some strange results, even only after reading the file_header.
This is my header :
typedef struct
{
WORD bfType;
DWORD bfSize;
WORD bfReserved1;
WORD bfReserved2;
DWORD bfOffBits;
} BITMAP_FILE_HEADER;
typedef struct
{
BITMAP_FILE_HEADER bitmapfileheader;
BITMAP_INFO bitmapinfo;
PALETTEENTRY palette[MAX_COLORS_PALETTE];
UCHAR * buffer;
} BITMAP_FILE, * BITMAP_FILE_PTR;
Here is the part where I read this header :
int LoadBitmap(const char* filename, BITMAP_FILE_PTR aBitmap)
{
FILE * bitmap_fp;
if ( (bitmap_fp = fopen(filename, "rb")) != NULL)
{
fread(&aBitmap->bitmapfileheader, sizeof(BITMAP_FILE_HEADER), 1,bitmap_fp);
// check for bitmap
if ( aBitmap->bitmapfileheader.bfType == BITMAP_ID )
{
The hex view of my bitmap is this :
42 4D 36 B4 04 00 00 00 00 00 36 04 00 00 28 00 ...
Using the Visual C++ debugger I get these values :
bfType = 19778 correct
bfSize = 4 (should be 308278, x04B436)
bfReserved1 = 0 correct
bfReserved2 = 1078 (should be 0, 1078 should be in OffBits)
bfOffBits = 2621440 incorrect
What goes wrong ?
Geert