MFC截取对话框指定位置的位图

xiaoxiao2025-05-27  49

    //保存位图

    CDC *pDC =  getDC();     CDC memDC;                    // 创建并绑定绘画DC和Bitmap     CBitmap bitmap;     memDC.CreateCompatibleDC(pDC);     bitmap.CreateCompatibleBitmap(pDC, x, y);         //图片的尺寸     memDC.SelectObject(&bitmap);

    // 把指定窗口区域的图片画到绘图DC中     memDC.BitBlt(0,0,w,h, pDC, 0, 0, SRCCOPY);        

    // 把Bitmap的图片保存到指定路径     CImage imgTemp;     imgTemp.Attach(bitmap.operator HBITMAP());     CString strTemp1 ;     strTemp1 += _T("\\view.bmp");     imgTemp.Save(strTemp1);

    memDC.DeleteDC();     bitmap.DeleteObject();  

转载请注明原文地址: https://www.6miu.com/read-5030791.html

最新回复(0)