CImage缩小图片时颜色失真

来源:互联网 发布:阿里云做网站号码 编辑:程序博客网 时间:2024/05/01 08:45
先把目标DC (也就是 HDC hDestDC) ::SetStretchBltMode(hDestDC, HALFTONE);
同时再调用一下  ::SetBrushOrgEx(hDestDC, 0, 0, NULL);

然后再调用CImage的StretchBlt


例如


SetStretchBltMode(pDC->m_hDC, STRETCH_HALFTONE);

    img.StretchBlt(pDC->GetSafeHdc(), CRect(0, 0, nWidth, nHeight), CRect((int)(rectZoomBorder.left*iWidthRate), \
        (int)(rectZoomBorder.top * iHeightRate), (int)(rectZoomBorder.right*iWidthRate), \
        (int)(rectZoomBorder.bottom * iHeightRate)));

    img.ReleaseDC();
    img.Destroy();