
Custom palettes in 256-color mode
I have the feeling I'm missing something obvious. The only way I can
get a new palette into a bitmap (VB5.0, machine in 256-color mode) is
by writing it out to disk, then using LoadPicture.
I use GetDIBits into a temp dc (CreateCompatibleDC) to get the DIB, then
modify its color table. Using SetDIBits to put it back into the
picture box gives me the original palette when the machine is in 256-
color mode (though I think it works correctly when the machine is in
hi-color mode), and this remapping onto the old palette is not what I
want. Writing the DIB to disk and loading it back in does what I want
here, but I'd like to do it without having to use the hard drive.
I tried building the new bitmap in memory (make a LOGPALETTE structure),
CreatePalette, SelectPalette, RealizePalette, CreateDIBitmap - all this
goes through without errors), then bltting it back onto the picture box
hDC. This gives a bitmap with no palette at all (at that point, the
picture box still has the old palette in it, so it could be a BitBlt
problem).
I tried the trick I've seen here, of putting the new palette into the
picture box first through the clipboard. That gets the palette in
there alright, but then I can't get the bitmap into it (BitBlt returns
a 1, but all I get is a 1x1 bitmap).
I also tried transferring the new bitmap from CreateDIBitmap through
the clipboard to the picture box. That gets the palette AND the
bitmap bits, but the result is incorrect (looks something like the
negative of the bitmap).
I've tried it with Autoredraw both true and false, tried a LoadPicture
just before blitting (that gives an empty bitmap - BitBlt w/different
palettes, again?).
Can anyone help?
Jim Janak.
Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.