CPaintDC dc(this); if (!m_hBitmap) return; image.Attach(m_hBitmap); CRect rect; GetClientRect(&rect);//获得控件所在的矩形区域 int width = rect.Width(); int height = rect.Height(); //...... CDC mDC; mDC.CreateCompatibleDC(&dc); CBitmap b; b.CreateCompatibleBitmap(&dc, width, height); mDC.SelectObject(&b); mDC.SetStretchBltMode(HALFTONE); mDC.FillSolidRect(0, 0, width, height, RGB(212, 208, 200));//设置背景颜色 image.StretchBlt(mDC.m_hDC, marginx, marginy, width-2*marginx, height-2*marginy); BitBlt(dc.m_hDC, 0, 0, width, height, mDC.m_hDC, 0, 0, SRCCOPY); mDC.DeleteDC(); ::DeleteObject(&b); m_hBitmap = image.Detach();
时间: 2024-10-19 07:48:17