Archived

This topic is now archived and is closed to further replies.

How do I load a bitmap?

This topic is 5981 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey all, how do I load a bitmap in C++? just some source code, that just loads a bitmap, thanks all, btw I have general knowlege of programing. thanks bye visit the best site ever: http://www.btinternet.com/~ashley.canning/index.html

Share this post


Link to post
Share on other sites
unsigned char *LoadBitmap(char *filename, BITMAPINFOHEADER *infoHeader)
{
BITMAPFILEHEADER fileHeader;

FILE *filePtr;

unsigned char *image;


filePtr = fopen( filename, "rb" );

fread( &fileHeader, sizeof(BITMAPFILEHEADER), 1, filePtr );

fread( infoHeader, sizeof(BITMAPINFOHEADER), 1, filePtr );

fseek( filePtr, fileHeader.bfOffBits, SEEK_SET );

image = ( unsigned char* )malloc( infoHeader->biSizeImage );

fread( image, 1, infoHeader->biSizeImage, filePtr );

fclose( filePtr );

return image;
}

Share this post


Link to post
Share on other sites
LoadImage(0, "arrow.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);

...returns a bitmap handle, and is a simple call to make. But what to do with it next depends on the API you''re using.

Share this post


Link to post
Share on other sites