11.04.2014 Views

Advanced MFC Programming

Advanced MFC Programming

Advanced MFC Programming

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Chapter 4. Button<br />

}<br />

pDC,<br />

rect.left,<br />

rect.top,<br />

SRCCOPY<br />

);<br />

memDCImage.BitBlt<br />

(<br />

0,<br />

0,<br />

rect.Width(),<br />

rect.Height(),<br />

&memDC,<br />

0,<br />

0,<br />

SRCINVERT<br />

);<br />

memDCImage.BitBlt<br />

(<br />

0,<br />

0,<br />

rect.Width(),<br />

rect.Height(),<br />

&memDCMask,<br />

0,<br />

0,<br />

SRCAND<br />

);<br />

memDCImage.BitBlt<br />

(<br />

0,<br />

0,<br />

rect.Width(),<br />

rect.Height(),<br />

&memDC,<br />

0,<br />

0,<br />

SRCINVERT<br />

);<br />

pDC->BitBlt<br />

(<br />

rect.left,<br />

rect.top,<br />

rect.Width(),<br />

rect.Height(),<br />

&memDCImage,<br />

0,<br />

0,<br />

SRCCOPY<br />

);<br />

}<br />

memDC.SelectObject(pOld);<br />

if(pBitmapMask != NULL)<br />

{<br />

memDCMask.SelectObject(pOldMask);<br />

memDCImage.SelectObject(pOldImage);<br />

}<br />

Bitmap copy is implemented by calling function CDC::BitBlt(…). This function will copy the selected<br />

bitmap from one DC to another. If there is no mask bitmap, we copy the normal bitmap (selected by memDC)<br />

directly to the target DC (pointed by pDC). Otherwise, first we copy the image pattern from the target device<br />

(pDC) to memory bitmap (selected by memDCImage). Then we copy normal bitmap and mask bitmap<br />

(selected by memDC and memDCMask) to this memory bitmap three times, using different operation modes,<br />

and copy the final result to the target DC (pDC). At last, we select the bitmaps out of DCs.<br />

84

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!