Monday, October 11, 2010

How to get all the screen colors red, green and blue values


Various programs running on the desktop, there are many very beautiful colors, we may want to use their color, but unfortunately there were no source, it is difficult to know exactly their R, G, B color value. So we have a lot of screen color pick tool, you want to know how they use the program to achieve the What? Here I use VC6.0 to do I took a screen color picker example of code to tell you that after running an instance of the interface is as follows:

Basic component ideas:

The principle is very simple and requires only a brief three-step. Both: get the screen DC, get the current mouse location in pixels, a pixel value decomposition of the red, green and blue can, it is easy now!

Key code:

1, access to the screen DC

HDC hDC =:: GetDC (NULL); file / / get the screen DC

2 pixels for the current mouse position

CPoint pt;
GetCursorPos (& pt); file / / get the current mouse location

COLORREF clr =:: GetPixel (hDC, pt.x, pt.y); file / / get the current pixel value the mouse

3, decomposition of the pixels in the red, green and blue color values

CString ClrText;
ClrText.Format ("% d", GetRValue (clr)); file / / the red value decomposition
ClrText.Format ("% d", GetGValue (clr)); file / / decomposition of the green value
ClrText.Format ("% d", GetBValue (clr)); file / / decomposition of the blue value

:: ReleaseDC (NULL, hDC); file / / release the screen DC

Concrete realization of the above part of the code details, download the example code in after carefully looking at the source can (with detailed comments).

Contact:
Address: Xi'an, Shaanxi Province Road on the 2nd hospital labor six units
Zip Code: 710082
OF EMAIL: jingzhou_xu@163.net
Future Studio (Future Studio)






Recommended links:



ASF converter



MKV to iPod



VOB to MP4



sysfader iexplore.exe application error fix it