ATL::CImage 使用范例

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u011430225/article/details/47043403
ATL::CImage m_rulerImages[NRULER_COUNT];
 (
{
    m_rulerImages[i].LoadFromResource(AfxGetInstanceHandle(),IDB_BITMAP_RULER1 + i);
}


void CDlgStaticImage::updateShowImage( const ATL::CImage& image )
{
    m_rulerImage.Destroy();
    m_rulerImage.Create(image.GetHeight(),image.GetWidth(),24);
    for (int j = 0; j < m_rulerImage.GetHeight(); ++j)
    {
        COLORREF color = image.GetPixel(m_rulerImage.GetHeight() - j -1,0);
        for (int i = 0; i < m_rulerImage.GetWidth(); ++i )
        {
            m_rulerImage.SetPixel(i,j,color);
        }
    }
}


if (!m_rulerImage.IsNull())
{
    CRect rect;
    GetClientRect(rect);

    dc.SetStretchBltMode(HALFTONE); //不掉用会导致图像失真
    dc.SetBrushOrg(0,0);

    m_rulerImage.StretchBlt(dc.GetSafeHdc(),rect);
}

PS:一个比较快的CImage像素访问办法


展开阅读全文

没有更多推荐了,返回首页