Link to home
Start Free TrialLog in
Avatar of ahtri
ahtri

asked on

Color and Pallete entry

I have an application that has the display come with a custome color pallete:

PALETTEENTRY ColourEntries[276];

When I get the color at the cursor by:

COLORREF PixelAtPointer = dc.GetPixel( point );

How to reference the COLORREF against the PALETTEENTRY ? I want to find the index of the pixel color in the pallete entry.

Thanks
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Use the Macros with the COLORREF for getting each color value

the macros are GetRValue(crf);GetGValue(crf);etc.

PALLETTEENTRY gives the bytes of the RGB,

So you can either combine these rgb value and compare with COLORREF , or split the COLORREF and compare with the pallette entry.


GOOD LUCK
Avatar of ahtri
ahtri

ASKER

how to split the COLORREF ? can you give me some sample code
COLORREF PixelAtPointer = dc.GetPixel( point );


BYTE byteRVal = GetRValue(PixelAtPointer);


GOOD LUCK
Avatar of ahtri

ASKER

I'm struggling to understand this code:

ShortRed=ColourEntries[i+20].peRed/8;     ShortGreen=ColourEntries[i+20].peGreen/4;
ShortBlue=ColourEntries[i+20].peBlue/8;

ColourIndex[i]=ShortRed*2048+ShortGreen*32+ShortBlue;

Do you have any idea about those "8", "4", "32", "2048" ?
ASKER CERTIFIED SOLUTION
Avatar of Roshan Davis
Roshan Davis
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial