Solved

code specifc; byte into int

Posted on 2007-11-26
5
217 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

808 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