Solved

code specifc; byte into int

Posted on 2007-11-26
5
215 Views
Last Modified: 2010-04-01
HDC hWindowDC = ::GetDC(hWnd);
(?)          COLORREF GetPixel(   HDC hWindowDC, int x, int y );



I have problem with the (?) part.
what type of variable do I use to store data from getpixel?


also, how do I convert those values into

int red
int green
int blue

?
0
Comment
Question by:Troudeloup
  • 3
  • 2
5 Comments
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20354125
COLORREF is a 32-bit value
0
 

Author Comment

by:Troudeloup
ID: 20354144
ok so I do

COLORREF pixel_color = GetPixel(   HDC hWindowDC, int x, int y );

and then
uh i never did this conversion before,

how do I do it?
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20354146
you can use as COLORREF color = GetPixel(......)
if you want to know independent color GetRValue(), GetGValue() and GetBValue() as

COLORREF color = GetPixel(someHDC, 50, 50); // just an example
int blue = GetBValue(color);

More help here:
http://msdn2.microsoft.com/en-us/library/aa923096.aspx

0
 

Author Comment

by:Troudeloup
ID: 20354154
int blue = GetBValue(color);

got it



how do you pro guys find all of these information?  it would be crazy if i think you are born with it.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20354165
msdn.microsoft.com
0

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

911 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

19 Experts available now in Live!

Get 1:1 Help Now