Solved

Color and Pallete entry

Posted on 2002-06-02
5
338 Views
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.

Thanks
0
Comment
Question by:ahtri
  • 3
  • 2
5 Comments
 
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.


GOOD LUCK
0
 

Author Comment

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

Expert Comment

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


BYTE byteRVal = GetRValue(PixelAtPointer);


GOOD LUCK
0
 

Author Comment

by:ahtri
ID: 7050440
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
 
LVL 23

Accepted Solution

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


And

second one is combining this for making the COLORREF

Roshmon
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
canBalance challenge 34 65
Fibonacci challenge 11 84
mapBully challenge 6 92
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 …
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.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

746 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

12 Experts available now in Live!

Get 1:1 Help Now