function to draw a bitmap in hdcdest
Get Desktop Code:
CDC *PDESKDC = GetDesktopWindow ()->getdc ();
CRect re;
Get the size of the window
GetDesktopWindow ()->getclientrect (&re);
CBitmap bmp;
Bmp. CreateCompatibleBitmap (PDESKDC, re. Width (), Re. Height ());
To create a compatible memory artboard
CDC MEMORYDC;
MEMORYDC. CreateCompatibleDC (PDESKDC);
Select brushes
CBitmap *pold = Memorydc. SelectObject (&bmp);
Drawing images
MEMORYDC. BitBlt (0,0,re. Width (), Re. Height (), PDESKDC, 0, 0, srccopy);
MEMORYDC. SelectObject (Pold);
BOOL BitBlt (
HDC hdcdest,
int nxdest, int nydest, int nwidth, int nheight,
HDC hdcsrc,
int nxsrc, int nysrc,
DWORD dwrop);
Parameters:
Hdcdest: A handle to the target device environment.
Nxdest, Nydest: Specifies the x-axis and y-axis logical coordinates of the upper-left corner of the target rectangular area
Nwidth, nheight: Specifies the logical width and logical height of the source and destination rectangular areas.
HDCSRC: A handle pointing to the source device environment.
NXSRC, NYSRC: Specifies the x-axis and y-axis logical coordinates of the upper-left corner of the source rectangular area.
Dwrop: Specifies the raster operation code. The code defines the color data for the source rectangular area, and how to combine the color data of the destination rectangular area to complete the final color. Some common raster operation codes are listed below:
The API documentation is described.
Blackness fills the destination rectangular area with black.
Dstinvert the target rectangular image to the reverse phase.
Mergecopy the source rectangle image with the specified pattern brush (patterns) for Boolean "and" operations.
Mergepaint a Boolean "or" operation with the target rectangle image after the source rectangular shape is reversed.
Notsrccopy copies the source rectangle image to the target rectangle after it has been reversed.
Notsrcerase the source rectangular image and the target rectangular image to the boolean "or" operation, and then the image is reversed.
Patcopy copies the specified pattern brush to the destination rectangle.
Patinvert the specified pattern brush with the target rectangle image for a Boolean "XOR" operation.
Patpaint first, the source rectangular image is reversed, with the specified pattern brush for Boolean "or" operations, and then with the target rectangular image boolean "or" Operation Srcand the source rectangle image and the target rectangular image of Boolean "and" operations.
Srccopy copies the source rectangle image directly onto the target rectangle.
Srcerase the target rectangular image to the reverse phase, and then to the source rectangular image Boolean "and" operation.
Srcinvert the source rectangular image and the target rectangular image in a Boolean "XOR" operation.
Srcpaint the source rectangular image with the target rectangular image for Boolean "or" operations.
Whiteness fills the target rectangular area with white.