BUG: GetDIBits Incorrectly Initializes the Color Table when Used On 1bpp and 4bpp DIB Sections (230499)



The information in this article applies to:

  • Microsoft Windows 2000 Server
  • Microsoft Windows 2000 Advanced Server
  • Microsoft Windows 2000 Professional
  • Microsoft Windows NT Server 4.0
  • Microsoft Windows NT Workstation 4.0
  • Microsoft Windows XP Home Edition
  • Microsoft Windows XP Professional
  • the operating system: Microsoft Windows XP 64-Bit Edition

This article was previously published under Q230499

SYMPTOMS

The colors in DIBs obtained through a conversion from 1 bit per pixel or 4 bits per pixel to 8 bits per pixel may not reflect the colors the original image was created with.

CAUSE

GetDIBits does not fill in the color table properly when converting either 1bpp or 4bpp DIB sections to 8bpp. Instead of initializing the color table of the 8bpp image using the colors from the color table of the source image, the color table is initialized with false values. The behavior of this function is incompatible with the behavior on Windows 95 and Windows 98.

RESOLUTION

Instead of using GetDIBits() to retrieve the bits directly from the DIB section, create an 8bpp DIB section and initialize its color table using the color table retrieved from the 1bpp/4bpp image. After this is done you can BitBlt() from the 1bpp/4bpp DIB section to the 8bpp DIB section in order to convert the format of the bits to 8bpp.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

Modification Type:MinorLast Reviewed:4/3/2006
Keywords:kbDSWGDI2003Swept kbBitmap kbbug kbDibSect kbFAQ kbGDI KB230499