GDI+绘制一幅图片

请先参考:GDI+的最初配置(VS2010)

void GdiDrawJpeg(HWND hWnd, HDC hdc)
{
    RECT lpRect;
    Gdiplus::Graphics graphics(hdc);
    Gdiplus::Image image(L"jt.jpg");
    GetClientRect(hWnd, &lpRect);//获取窗口客户区的坐标
    int hight = lpRect.bottom - lpRect.top;
    int width = lpRect.right - lpRect.left;
    Gdiplus::Point PointLeftTop(0, 0);
    Gdiplus::Point PointRightTop(width, 0);
    Gdiplus::Point PointLeftBottom(0, hight);
    Gdiplus::Point destPara[3] = {PointLeftTop, PointRightTop, PointLeftBottom};
    //graphics.DrawImage(&image, 0, 0, width, hight);
    graphics.DrawImage(&image, destPara, 3);
}

建议:在WM_CREATE消息里面装载GDI+,在WM_DESTROY消息里面卸载GDI+,在WM_ERASEBKGND消息(当窗口背景必须被擦除时,例在窗口改变大小时)里调用GdiDrawJpeg函数。

你可能感兴趣的:(image,2010,GDI+)