GDI + double buffering

Source: Internet
Author: User

Memory BMP Mode

1. Initialize
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. Draw pgraphics-> in memory BMP

3. Draw the memory BMP to the window DC
pgraphicswnd->drawimage (Pbitmap, x0, y0, width, height) ;

4. Release
Gdiplus::D llexports::gdipfree (pgraphics);
Gdiplus::D llexports::gdipfree (pbitmap);
Gdiplus::D llexports::gdipfree (Pgraphicswnd);

BitBlt Way

1. Initialize
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. Draw pgraphics-> into the memory
DC

3. Copy the contents of the memory DC to the window DC
StretchBlt (hdc, 0, 0, W, H, hdcmemory, 0, 0, W, h, srccopy);

4. Release
Gdiplus::D llexports::gdipfree (pgraphics);
DeleteObject (HOLDBITMAP);
DeleteObject (HBITMAP);
DeleteObject (hdcmemory);


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.