void CmyImage006View::OnDraw(CDC *pDC)
{
/*
CmyImage006Doc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
if (!pDoc)
return;
*/
CBitmap bitmap;
CDC cmc;
bitmap.LoadBitmapW(IDB_BITMAP2);
BITMAP bmp;
bitmap.GetBitmap(&bmp);
//bitmap.GetBitmap(&bmp);
cmc.CreateCompatibleDC(pDC);
cmc.SelectObject(&bitmap);
//pDC->BitBlt(0,0,619,619,&cmc,0,0,SRCCOPY);
// pDC->StretchBlt(0,0,619/2,619/2,&cmc,0,0,619,619,SRCCOPY);
//pDC->BitBlt(0,0,800,800,&cmc,0,0,SRCCOPY);
CRect cm;
GetClientRect(&cm);
// pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,1024,1024,SRCCOPY);
// pDC->BitBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,SRCCOPY);
//pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
pDC->StretchBlt(0,0,cm.Width(),cm.Height(),&cmc,0,0,bmp.bmWidth,bmp.bmHeight,SRCCOPY);
// TODO: add draw code for native data here
}VS2010-MFC内显示图片
最新推荐文章于 2022-04-11 12:00:49 发布
本文介绍了一个名为CmyImage006View的类中的OnDraw方法实现,该方法使用CDC和CBitmap类来加载并绘制位图。通过创建与设备兼容的上下文、选择位图对象,并使用StretchBlt进行拉伸绘制,实现了位图的自适应显示。

924

被折叠的 条评论
为什么被折叠?



