Solved

Color and Pallete entry

Posted on 2002-06-02
5
348 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 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