Draw device-related bitmaps, icons, and device-independent bitmaps in the window.

Source: Internet
Author: User

 

InIn Windows, pre-prepared images can be copied to the display area. This memory copy is very fast. There are two ways to copy images in Windows: Device-related Bitmap (DDB) and device-independent Bitmap (DIB ).

DDB can be represented by CBitmap in MFC, while DDB is generally stored in resource files. During loading, you only need to use the resource ID to load the images. BOOL CBitmap: LoadBitmap (UINT nIDResource) can be loaded into a specified DDB, but it must be implemented by using another memory DC compatible with the current drawing DC. Use CDC: BitBlt (int x, int y, int nWidth, int nHeight, CDC * pSrcDC, int xSrc, int ySrc, DWORD dwdrop) to draw a graph, specify the type of the grating operation. BitBlt can copy bitmap from the source DC to the Target DC. The first four parameters are the coordinates of the target region, the source DC pointer is followed by the starting coordinates of the source DC, because BitBlt is proportional replication, you do not need to specify the length and width again. (StretchBlt can be scaled.) The last parameter is the type of the grating operation. The following values are recommended:

  • BLACKNESSThe output area is black Turns all output black.
  • DSTINVERTReversed output area Inverts the destination bitmap.
  • MERGECOPYUse AND to operate Combines the pattern and the source bitmap using the Boolean AND operator between the source AND target.
  • MERGEPAINTUse OR to Combines the inverted source bitmap with the destination bitmap using the Boolean OR operator between the background and source.
  • NOTSRCCOPYCopy the reversed source to the destination Copies the inverted source bitmap to the destination.
  • PATINVERTPerform XOR operations between the source and target Combines the destination bitmap with the pattern using the Boolean XOR operator.
  • SRCANDAND between the source and destination Combines pixels of the destination AND source bitmaps using the Boolean AND operator.
  • SRCCOPYCopy the source to the destination Copies the source bitmap to the destination bitmap.
  • SRCINVERTPerform XOR operations between the source and target Combines pixels of the destination and source bitmaps using the Boolean XOR operator.
  • SRCPAINTPerform the OR operation between the source and target Combines pixels of the destination and source bitmaps using the Boolean OR operator.
  • WHITENESSThe output area is white Turns all output white.

The following code demonstrates this method:

CYourView: OnDraw (CDC * pDC)
  
{
  
CDC memDC; // defines a compatible DC
  
MemDC. CreateCompatibleDC (pDC); // create a DC
  
CBitmap BMP draw;
  
BMP d

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.