PRB: LoadImage Alters Color Table with 256 Color Bitmaps

ID: Q195831

The information in this article applies to:

SYMPTOMS

When you load a .bmp file with the LoadImage API under Windows NT, the color table of the loaded image might not match the color table of the original .bmp file. Typically, this problem occurs when you load a 256 color image that has multiple color table entries with the same RGB value. In these cases, the loading process causes each of the duplicated RGB values to be remapped to the first occurrence in the color table of the same RGB value.

NOTE: This behavior only occurs under Windows NT. It does not occur under Windows 95 or Windows 98.

RESOLUTION

The simplest way to work around this problem is to avoid using the LoadImage() API, and use your own code to load the bitmaps. please see the following article in the Microsoft Knowledge Base for a sample that contains a library of functions for loading, modifying, converting, and saving .bmp files:

   ARTICLE-ID: Q94326
   TITLE     : SAMPLE: SeedIB.exe Shows 16 and 32 Bits-Per-Pel Bitmap
               Formats

Additional query words:
Keywords          : kbAPI kbBitmap kbGDI 
Issue type        : kbprb

Last Reviewed: November 17, 1998