Solved

code specifc; byte into int

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

707 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

18 Experts available now in Live!

Get 1:1 Help Now