Using GetDIBits() for Retrieving Bitmap Information

Last reviewed: November 2, 1995
Article ID: Q85846
The information in this article applies to:
  • Microsoft Win32 Application Programming Interface (API) included with:

        - Microsoft Windows NT versions 3.1 and 3.5
        - Microsoft Windows 95 version 4.0
    

SUMMARY

When saving a bitmap in .DIB file format, the GDI function is used to retrieve the bitmap information. The general use of this function and the techniques for saving a bitmap in .DIB format are largely unchanged; however, this article provides more details on the use of the Win32 API version of the GetDIBits() function.

MORE INFORMATION

The function can be used to retrieve the following information:

  • Data in the BitmapInfoHeader (no color table and no bits)
  • Data in the BitmapInfoHeader and the color table (no bits)
  • All the data (BitmapInfoHeader, color table, and the bits)

The fifth and the sixth parameters of the function are used to tell the graphics engine exactly what the application wants it to return. If the fifth parameter is NULL, then no bits will be returned. If the biBitCount is 0 (zero) in the sixth parameter, then no color table will be returned. In addition, the biSize field of the BitmapInfoHeader must be set to either the size of BitmapInfoHeader or BitmapCoreHeader for the function to work properly.

Refer to the SAVEBMP.C file in the MANDEL sample for details. This sample is included with the Win32 SDK.


Additional reference words: 3.10 3.50 4.00 95
KBCategory: kbgraphic
KBSubcategory: GdiBmp


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: November 2, 1995
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.