Quote:Original post by programering
I need to load a bitmap from a FILE *pFile ptr, how todo that?
And how to blit it? The prototype for blitting takes a HDC.
BOOL BitBlt(
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
);
To convert it seems to be a bit complicated.
BTW, what the difference between BITMAP/HBITMAP and HDC?
The only image format that Win32 API seems to support is just *.bmp, why?
Do you
really need to load from a FILE*? Or do you just want to laod from a file on disk? Loading from a FILE* will involve parsing the file youself, since the Win32 methods don't have any concept of FILE*'s. So you'd need to allocate an empty HBITMAP, then parse the file into it.
If you want to load from a file on disk, then you can use
LoadImage and specify the LR_LOADFROMFILE flag.
I'd advise having a look around google for some Win32 GDI tutorials - I intend to write one myself soon.
Basically, all drawing operations use HDCs, which is a Handle to a Device Context. A HDC is basically where all the drawing commands go. The HDC usually represents a monitor, but it can also represent a printer and things too.
To draw onto a bitmap, you select the HBITMAP into the HDC using SelectObject(), which sort of attaches the bitmap to the HDC for use. You do the same with HPENs, HBRUSHes, and anything else if you want to draw.
Once you have the bitmap selected into the HDC you can use the BitBlt() command to blit rectangular regions of the device context to another device context, which copies chunks of the bitmap.