Selecting a palette in 256 color mode
Posted on 1998-08-17
I have a bitmap which is drawn in a specific palette, and would like to draw this bitmap using that palette when my application is using 256 color mode.
I have created a bitmap resource, and used VC++'s resource editor's Load Palette dialog to load my palette. My bitmap looks fine in the resource editor's bitmap display. However, also in the resource editor, my bitmap is flattened to 16 color when I use the bitmap in a dialog resource.
My bitmap is also drawn in 16 colors when that dialog is displayed by my application.
What I have tried:
Please do not answer this question, suggesting that I try any of the following, since I already have.
I have a function that returns an HPALETTE, given a bitmap filename. I use this function to get the palette out of a palette.bmp file I intend to ship with my application. I have then tried calling SelectPalette and RealizePalette from the following callbacks:
OnInitDialog, OnPaint, OnQueryNewPalette
None of these worked.
A friend told me that when calling LoadBitmap in 256 color mode, that windows automatically reduces the image to 16 colors, so the information is lost. He says the only way to draw the image in the 256 colors is to create the bitmap yourself and realize the palette in its DC, then draw it yourself into the dialog.
I think there must be a better way.
Can you give me an easy solution that will allow me to draw a bitmap into a dialog, using a specific palette that I have access to?