DirectDraw colour matching [Archive] - C Board

PDA

View Full Version : DirectDraw colour matching


Hunter2
12-09-2002, 05:45 PM
So I have this ready-made function that matches colours to the closest available colour that can be displayed. It:

a) gets an HDC for a DirectDraw surface

b) saves the pixel that is at (0,0)

c) uses SetPixel() to set it to the colour passed in the arguments

d) goes through a bunch of other painful-looking steps to figure out what colour was used (i.e. "lock the surface", then "get DWORD", then "Mask it to bpp")

e) sets the pixel back to the original colour.


My question is, couldn't it just

a) get the pixel
b) use SetPixelV() to set it to the "closest approximation of" the passed colour
c) GetPixel() to find the colour that was used
d) set the pixel back to the original colour

Wouldn't that work just as well? (anyways, what's up with the masking to bpp?)

master5001
12-09-2002, 11:25 PM
Not if you are trying to match a system palette.

Hunter2
12-10-2002, 02:17 PM
Ok, I'll take your word for it. :( Guess I'll just have to figure out how the function works.