How do I load a bitmap?

Started by
2 comments, last by AC AC 22 years, 8 months ago
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
visit the best site ever:http://www.btinternet.com/~ashley.canning/index.html
Advertisement
Check out the theForger tutorials and FAQ for all your C++ Win32 API needs.

www.winprog.org/tutorial
------------------------



  Downloads:  ZeroOne Realm

  Downloads:  ZeroOne Realm

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;
}
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.

This topic is closed to new replies.

Advertisement