Custom palettes in 256-color mode 
Author Message
 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.



Fri, 25 Jan 2002 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. Custom 24-bit colors in 256-color mode

2. Still need help with palette for 256 color mode

3. Palette Problems in 256 Color Mode

4. Palette Problems in 256 Color Mode

5. Custom 256-color palettes - how??

6. Using 256 color Palettes in High/True Color

7. choose a color in a 256 color palette ?

8. Change Screen Color Palette from 256 to hi-color in VB

9. Bitmap Color Palette editing-VB4 16 bit 256 color

10. Coloring a control from a 256-Color palette

11. Coloring a control from a 256-Color palette

12. color palette not accessible in 256+ color settings

 

 
Powered by phpBB® Forum Software