BitBlt functions in C + +

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.