为什么StretchBlt缩放后成了这个样子,该如何处理
为什么StretchBlt缩放后成了这个样子
在内存中画图,然后用StretchBlt画到picturebox上,怎么缩放后有一部分没出来,button1代码如下:
[code=C/C++][/code] CDC* pDC = GetDlgItem(IDC_STATIC)->GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CRect RectPicturebox;
GetDlgItem(IDC_STATIC)->GetClientRect(&RectPicturebox);
CBitmap bmp;
bmp.CreateCompatibleBitmap(pDC,RectPicturebox.Width(),RectPicturebox.Height());
CBitmap *pOldbmp = memDC.SelectObject(&bmp);
CRect rect;
rect.bottom = 400;
rect.top = 0;
rect.left = 0;
rect.right = 400;
memDC.Ellipse(&rect);
pDC->SetStretchBltMode(STRETCH_HALFTONE | STRETCH_ORSCANS);
pDC->StretchBlt(0,0,RectPicturebox.Width(),RectPicturebox.Height(),&memDC,0,0,rect.Width(),rect.Height(),SRCCOPY);
------解决方案--------------------
CRect rect;
rect.bottom = 400;
rect.top = 0;
rect.left = 0;
rect.right = 400;
你这里的400,400是图片的大小码?
------解决方案--------------------
在内存中画图,然后用StretchBlt画到picturebox上,怎么缩放后有一部分没出来,button1代码如下:
[code=C/C++][/code] CDC* pDC = GetDlgItem(IDC_STATIC)->GetDC();
CDC memDC;
memDC.CreateCompatibleDC(pDC);
CRect RectPicturebox;
GetDlgItem(IDC_STATIC)->GetClientRect(&RectPicturebox);
CBitmap bmp;
bmp.CreateCompatibleBitmap(pDC,RectPicturebox.Width(),RectPicturebox.Height());
CBitmap *pOldbmp = memDC.SelectObject(&bmp);
CRect rect;
rect.bottom = 400;
rect.top = 0;
rect.left = 0;
rect.right = 400;
memDC.Ellipse(&rect);
pDC->SetStretchBltMode(STRETCH_HALFTONE | STRETCH_ORSCANS);
pDC->StretchBlt(0,0,RectPicturebox.Width(),RectPicturebox.Height(),&memDC,0,0,rect.Width(),rect.Height(),SRCCOPY);
------解决方案--------------------
CRect rect;
rect.bottom = 400;
rect.top = 0;
rect.left = 0;
rect.right = 400;
你这里的400,400是图片的大小码?
------解决方案--------------------
- C/C++ code
CDC* pDC = GetDlgItem(IDC_STATIC1)->GetDC(); CDC memDC; memDC.CreateCompatibleDC(pDC); CRect RectPicturebox; GetDlgItem(IDC_STATIC1)->GetClientRect(&RectPicturebox); CBitmap bmp; bmp.CreateCompatibleBitmap(pDC,RectPicturebox.Width(),RectPicturebox.Height()); CBitmap *pOldbmp = memDC.SelectObject(&bmp); CRect rect; rect.bottom = RectPicturebox.Height(); rect.top = 0; rect.left = 0; rect.right = RectPicturebox.Width(); memDC.Ellipse(&rect); pDC->SetStretchBltMode(STRETCH_HALFTONE | STRETCH_ORSCANS); pDC->StretchBlt(0,0,RectPicturebox.Width(),RectPicturebox.Height(),&memDC,0,0,rect.Width(),rect.Height(),SRCCOPY); memDC.SelectObject(pOldbmp); memDC.DeleteDC(); GetDlgItem(IDC_STATIC1)->ReleaseDC(pDC);