I looked up _lread in the MSVC++ help and it says I should use readfile(), but I'm having a hard time with it. I can't even do basic things like reading in a string. BTW here's the code from my book:
Code:
int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)
{
int file_handle, index;
UCHAR *temp_buffer = NULL;
OFSTRUCT file_data;
if ((file_handle = OpenFile(filename,&file_data,OF_READ))==-1)
return(0);
_lread(file_handle, &bitmap->bitmapfileheader,sizeof(BITMAPFILEHEADER));
if (bitmap->bitmapfileheader.bfType!=BITMAP_ID)
{
_lclose(file_handle);
return(0);
}
_lread(file_handle, &bitmap->bitmapinfoheader,sizeof(BITMAPINFOHEADER));
if (bitmap->bitmapinfoheader.biBitCount == 8)
{
_lread(file_handle, &bitmap->palette,MAX_COLORS_PALETTE*sizeof(PALETTEENTRY));
for (index=0; index < MAX_COLORS_PALETTE; index++)
{
int temp_color = bitmap->palette[index].peRed;
bitmap->palette[index].peRed = bitmap->palette[index].peBlue;
bitmap->palette[index].peBlue = temp_color;
bitmap->palette[index].peFlags = PC_NOCOLLAPSE;
}
}
_lseek(file_handle,-(int)(bitmap->bitmapinfoheader.biSizeImage),SEEK_END);
if (bitmap->bitmapinfoheader.biBitCount==8 || bitmap->bitmapinfoheader.biBitCount==16 ||
bitmap->bitmapinfoheader.biBitCount==24)
{
if (bitmap->buffer)
free(bitmap->buffer);
if (!(bitmap->buffer = (UCHAR *)malloc(bitmap->bitmapinfoheader.biSizeImage)))
{
_lclose(file_handle);
return(0);
}
_lread(file_handle,bitmap->buffer,bitmap->bitmapinfoheader.biSizeImage);
} // end if
else
{
return(0);
}
_lclose(file_handle);
Flip_Bitmap(bitmap->buffer,
bitmap->bitmapinfoheader.biWidth*(bitmap->bitmapinfoheader.biBitCount/8),
bitmap->bitmapinfoheader.biHeight);
return(1);
}
Sorry it's so long, but thanks in advance for any help
*EDIT*
Took out long comments/big whitespace. BTW the struct for bitmap is only what members are in the code above