Log in

View Full Version : Palette hell



nzo2
10-05-2007, 10:33 PM
Bah.

I really don't understand how I can get the colour of a pixel in an 8 bit DIB and convert it for use on a 16bit surface. All my Imagelist items are easily converted I know, but when I process a DIB and try to pixel set the DXDraw surface, it is always the wrong colours.

I did make a "special" sprite which I can use with the Pixel routines of TurboPixels etc. but this is only ok if I initialise a static image once only (way too slow).

I have tried many ways and converting of the pixel / colourtables, but no luck.

e.g. The 8 bit palette value at DIB.ColorTable[x] => pixel data on 16bit screen....

The colours exist in the 16bit palette because the graphic was sourced from the Imagelist, and don't suggest ColorMatch :)

I have studied the DXDraw.UpdatePalette, but cannot see where my "specific" palette of e.g. image[29] is set.

Hope there are still some DelphiX people persevering out there :)

nzo2
10-05-2007, 11:14 PM
I have taken this so far:

Assume I get the correct palette index of the 8bit image by checking a pixel from a ScanLine in the 8bit DIB

col:=scan(DXD_Scratch.DIB.ScanLine[y]^)[X];

Then, I get the correct colour as an RGBQuad from the DIB colour table like:

q:=DXD_Scratch.DIB.ColorTable[col];

I have checked col and q and both contain the correct data, so all that remains is setting the pixel of the 16bit DXDraw surface.

I have tried all ways I can find to get the target pixel the right colour, but no luck... I am pulling my hair out :x