Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 370
  • Last Modified:

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
0
ahtri
Asked:
ahtri
  • 3
  • 2
1 Solution
 
Roshan DavisCommented:
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
0
 
ahtriAuthor Commented:
how to split the COLORREF ? can you give me some sample code
0
 
Roshan DavisCommented:
COLORREF PixelAtPointer = dc.GetPixel( point );


BYTE byteRVal = GetRValue(PixelAtPointer);


GOOD LUCK
0
 
ahtriAuthor Commented:
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" ?
0
 
Roshan DavisCommented:
First one is splitting the COLORREF


And

second one is combining this for making the COLORREF

Roshmon
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now