内存bmp方式
1. 初始化
Gdiplus::Bitmap* pBitmap = new Gdiplus::Bitmap(w,h);
Gdiplus::Graphics* pGraphics = Gdiplus::Graphics::FromImage(pBitmap);
pGraphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
pGraphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
HDC hdc = GetDC(hWnd);
Gdiplus::Graphics* pGraphicsWnd = new Gdiplus::Graphics(hdc);2. 往内存bmp中绘制
pGraphics->3. 把内存bmp绘制到窗口dc中
pGraphicsWnd->DrawImage(pBitmap, x0, y0, width, height);4. 释放
Gdiplus::DllExports::GdipFree(pGraphics);
Gdiplus::DllExports::GdipFree(pBitmap);
Gdiplus::DllExports::GdipFree(pGraphicsWnd);
bitblt方式
1. 初始化
HDC hdc = GetDC(hWnd);
HDC hdcMemory = CreateCompatibleDC(hdc);
HBITMAP hBitmap = CreateCompatibleBitmap(hdc, w, h);
HBITMAP hOldBitmap = (HBITMAP)SelectObject(hdcMemory, hBitmap);
Gdiplus::Graphics* pGraphics = new Gdiplus::Graphics(hdcMemory);
pGraphics->SetSmoothingMode(Gdiplus::SmoothingModeHighQuality);
pGraphics->SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);2. 往内存dc中绘制
pGraphics->3. 把内存dc的内容copy到窗口dc中
StretchBlt(hdc, 0, 0, w, h, hdcMemory, 0, 0, w, h, SRCCOPY);4. 释放
Gdiplus::DllExports::GdipFree(pGraphics);
DeleteObject(hOldBitmap);
DeleteObject(hBitmap);
DeleteObject(hdcMemory);