Solved

Color and Pallete entry

Posted on 2002-06-02
5
346 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 Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Title # Comments Views Activity
how do i create updater to My Activex application? 3 95
Expand macro to ask for filename column 8 37
format the code in java 6 101
matchUp  challenge 9 115
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.

828 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