INFO: Using GetDIBits() for Retrieving Bitmap Information (85846)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • Microsoft Windows NT Server 3.1
    • Microsoft Windows NT Server 3.5
    • Microsoft Windows NT Workstation 3.1
    • Microsoft Windows NT Workstation 3.5
    • Microsoft Windows 95

This article was previously published under Q85846

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.

Modification Type:MinorLast Reviewed:2/11/2005
Keywords:kbinfo KB85846