Gdiplus 双缓冲显示图片

    HDC hdcPreview = ::GetDC(hwndPreview);//设备dc
    Gdiplus::Graphics tp_graphics(hdcPreview);

//1.直接绘制
    //tp_status_return = tp_graphics.DrawImage(&tp_bitmap_showImage,tp_GdiRect);
/*2.双缓冲绘制方案1
    Gdiplus::Bitmap tp_membitmap((INT)dcWidth, (INT)dcHeight);
    Gdiplus::Graphics tp_memGraphics(&tp_membitmap);//
    tp_memGraphics.Clear(Color(255, 255, 255));
    tp_memGraphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
    tp_memGraphics.ScaleTransform(tp_zoom, tp_zoom);
    tp_memGraphics.DrawImage(&tp_bitmap_showImage, tp_GdiRect,0,0,W,H,Gdiplus::UnitPixel);
    tp_status_return = tp_graphics.DrawImage(&tp_membitmap, 0,0);*/
//3、双缓冲绘制方案2
    Gdiplus::Bitmap tp_membitmap((INT)dcWidth, (INT)dcHeight);//
    Gdiplus::Graphics tp_memGraphics(&tp_membitmap);
    tp_memGraphics.Clear(Color(255, 255, 255));//清楚缓存
    tp_memGraphics.SetSmoothingMode(Gdiplus::SmoothingModeNone);
    tp_memGraphics.ScaleTransform(tp_zoom, tp_zoom);
    tp_memGraphics.DrawImage(&tp_bitmap_showImage, tp_GdiRect, 0, 0, W, H, Gdiplus::UnitPixel);//Drawing on bitmap

    CachedBitmap tp_cachedBmp(&tp_membitmap, &tp_graphics);//Drawing on DC
    tp_status_return=tp_graphics.DrawCachedBitmap(&tp_cachedBmp, 0, 0);

你可能感兴趣的:(C++编程,MFC,Gdiplus)