Color and Pallete entry

Posted on 2002-06-02
Last Modified: 2013-11-20
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.

Question by:ahtri
  • 3
  • 2
LVL 23

Expert Comment

by:Roshan Davis
ID: 7050407
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.


Author Comment

ID: 7050419
how to split the COLORREF ? can you give me some sample code
LVL 23

Expert Comment

by:Roshan Davis
ID: 7050424
COLORREF PixelAtPointer = dc.GetPixel( point );

BYTE byteRVal = GetRValue(PixelAtPointer);


Author Comment

ID: 7050440
I'm struggling to understand this code:

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


Do you have any idea about those "8", "4", "32", "2048" ?
LVL 23

Accepted Solution

Roshan Davis earned 50 total points
ID: 7050452
First one is splitting the COLORREF


second one is combining this for making the COLORREF


Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Rewrite URL With Encoded Characters 6 75
canBalance challenge 34 70
matchUp  challenge 9 94
Thin secure Windows 10 5 76
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Internet Business Fax to Email Made Easy - With  eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now