GDI+ 图片高亮处理

最近做图片高亮处理,网上找了点资料,自己整理了下

 

方法1: 

    
    m_RowImage= Gdiplus::Image::FromFile(L"gridhead.png",true);

    
     Gdiplus:: ColorMatrix HotMat = 
        {1.05f, 0.00f, 0.00f, 0.00f,0.00f,
        0.00f, 1.05f, 0.00f, 0.00f, 0.00f,
        0.00f, 0.00f, 1.05f, 0.00f, 0.00f,
        0.00f, 0.00f, 0.00f, 1.00f, 0.00f,
        0.05f, 0.05f, 0.05f, 0.00f, 1.00f};

        Gdiplus:: ImageAttributes imageAttr; 

        imageAttr.SetColorMatrix(&HotMat);

        Gdiplus:: RectF rcDrawRect;
        rcDrawRect.X=0;
        rcDrawRect.Y=0;
        rcDrawRect.Width=100;
        rcDrawRect.Height=100;

        HDC hdc=GetDC(m_HWND);
        Gdiplus::Graphics graphics(hdc);
        graphics.DrawImage(m_RowImage,rcDrawRect,0,0,1,m_ColumnHeight,Gdiplus:: UnitPixel,&imageAttr);
      ReleaseDC(m_HWND,hdc);

 

方法2 SetGamma

   m_RowImage= Gdiplus::Image::FromFile(L"gridhead.png",true);

     Gdiplus:: ImageAttributes imageAttr; 

      imageAttr.SetGamma( 1/2.2f );

        Gdiplus:: RectF rcDrawRect;

        rcDrawRect.X=0;
        rcDrawRect.Y=0;
        rcDrawRect.Width=100;
        rcDrawRect.Height=100;

        HDC hdc=GetDC(m_HWND);
        Gdiplus::Graphics graphics(hdc);
        graphics.DrawImage(m_RowImage,rcDrawRect,0,0,1,m_ColumnHeight,Gdiplus:: UnitPixel,&imageAttr);
      ReleaseDC(m_HWND,hdc);

 

posted @ 2013-01-31 15:58  Hideaway  阅读(853)  评论(0编辑  收藏  举报