SAMPLE: Drawing to a Memory Bitmap for Faster Performance

Last reviewed: February 15, 1996
Article ID: Q130805
The information in this article applies to:
  • Microsoft Windows Software Development Kit (SDK) for Windows version 3.1
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT version 3.5
        - Microsoft Windows 95 version 4.0
        - Microsoft Win32s version 1.2
    

An application whose client area is a complex image can realize a performance benefit from drawing to a memory bitmap. The complex, time consuming drawing code need only be performed once - to initialize the offscreen bitmap. During the handling of the WM_PAINT message, the only work that needs to be done is a simple BitBlt from the memory bitmap to the screen.

Sample code demonstrating this technique is available in the Microsoft Software Library. The MemDC sample code draws a complex pattern on its client area. A menu option toggle allows the user to see the speed difference between using and not using the offscreen bitmap.

Download MEMDC.EXE, a self-extracting file, from the Microsoft Software Library (MSL) on the following services:

  • Microsoft Download Service (MSDL)

          Dial (206) 936-6735 to connect to MSDL
          Download MEMDC.EXE (size: 23553 bytes) 
    
  • Internet (anonymous FTP)

          ftp ftp.microsoft.com
          Change to the \SOFTLIB\MSLFILES directory
          Get MEMDC.EXE (size: 23553 bytes) 
    


Additional reference words: 1.20 3.10 3.50 4.00 95 device context memory DC
speed fast buffer
KBCategory: kbgraphic kbfile
KBSubcategory: GdiDc


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 15, 1996
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.