PRB: UnrealizeObject() Causes Unexpected Palette BehaviorLast reviewed: November 2, 1995Article ID: Q86800 |
The information in this article applies to:
SYMPTOMSIn an application for the Microsoft Windows graphical environment, when a logical palette (HPALETTE) is used with a device-dependent bitmap (DDB) and the application realizes the palette, the DDB is painted in incorrect colors.
CAUSEThe UnrealizeObject function was previously called to unrealize the palette.
RESOLUTIONModify the code to remove the call to UnrealizeObject()/
MORE INFORMATIONBecause the colors of a DDB are stored using indices into the system palette rather than explicit RGB colors, proper DDB rendering depends on the colors of the system palette being set properly. An application sets up the system palette to display a DDB by realizing a logical palette. The realization process changes the colors in the system palette and creates a mapping between entries in the logical palette and entries in the system palette. When an application first renders a logical palette with RealizePalette(), Windows sets an internal flag to indicate that the palette has been realized and stores the current mapping from logical palette entries to physical palette entries. When an application realizes the palette again (for example, after another application modifies the palette), Windows restores the effected entries of the system palette to the state they had when the logical palette was realized for the first time. This mechanism allows a bitmap first realized with a specific palette to display correctly when the same palette is realized subsequently. If the application calls UnrealizePalette() on a logical palette, Windows discards the stored state information for the palette. If the application realizes the palette subsequently, its colors may map into new locations in the system palette. Because the bitmap contains indices into the old system palette, it may display incorrectly. To address this situation, do not call UnrealizeObject() on a palette if the application has a DDB that depends on that palette.
|
Additional reference words: 3.00 3.10 3.50 4.00 95
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |