Archived

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

AC AC

How do I load a bitmap?

Recommended Posts

AC AC    122
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
asaari    122
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
Beer Hunter    712
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