Home > Software engineering >  A novice for help: based on the VS2010 win32 or MFC drawing bitmap
A novice for help: based on the VS2010 win32 or MFC drawing bitmap

Time:10-05

Novice one, ask the great spirit how to draw a bitmap in the win32 platform, and will be more SFC tutu place them on this piece of bitmap, a great god, please give the specific procedures or relevant example, thank you.

CodePudding user response:


First from the dialog box to import a bitmap resources, resource ID for the IDB_BITMAP1,
And then:

CRect rc;
GetWindowRect (& amp; Rc);
The CDC * pDC.
The CDC memdc;
CBitmap * olddc;
CBitmap bitmap.
Bitmap. LoadBitmap (IDB_BITMAP1);
PDC=this - & gt; GetDC ();
Memdc. CreateCompatibleDC (pDC);
Olddc=memdc. SelectObject (& amp; Bitmap);
PDC - & gt; BitBlt (0, 0, rc. Width (), rc, Height (), & amp; Memdc, 0, 0, SRCCOPY);

If (olddc)
{
Memdc. SelectObject (olddc);
}

CodePudding user response:

CImag img.
Img. Load (XXX);

CodePudding user response:

 
CImage img, imgOld;
ImgOld. Load (" 1. JPG ");//a larger version
Img. Load (" 2. JPG ");//insets
HDC dcmem.=imgOld GetDC ();
SetStretchBltMode (dcmem, HALFTONE);//to prevent distortion
//painting picture on the big picture
Img. StretchBlt (dcmem, the top left corner of the destination rectangle coordinates X axis, Y axis of the left upper corner of the destination rectangle coordinates, the width of the destination rectangle, specify the height of the destination rectangle, the top left corner of the source rectangle coordinates X axis, the top left corner of the source rectangle Y coordinates, the width of the source rectangle, the height of the source rectangle, SRCCOPY);
//on the controls on
ImgOld. The Draw (GetDlgItem (ID) control - & gt; GetDC () - & gt; M_hDC, CRect (on the left border, boundary, right border, border));
//save picture
ImgOld. Save (" 222 JPG ");
ImgOld. ReleaseDC ();
  • Related