CColor class Overview

encapsulates the GDI color value (COLORREF)

provided by: 
Originally published at Internet.com


This article was contributed by Christian Rodemeyer. [Method overview] The class CColor encapsulates the GDI color value (COLORREF) and adds some comfortable functions: direct manipulation of RGB and HSL attributes, conversion to string values for storage (registry, databases) and user-friendly color names. By userdefined constructors and conversions is it possible to use a CColor object everywhere a COLOREF value is expected. The attributes red, green and blue can be separatly accessed. This is an improvement compared with the use of makros like RGB, GetRValue, GetBValue and GetGValue. Likewise the attributes of the HLS color model (hue, luminance and saturation) can be separatly read and manipulated. In this manner it is very easy to draw color gradients like the title bars of Windows98 application or a "Choose Color" dialog. The MSDN Library provides an article which describes the HLS color model under the title "HLS Color Spaces". Colors could principially be stored in the registry or in databases numerically as DWORDs, but their manipulation through regedit like tools or SQL is unneccessarily complicated in this form. But it is more clever to store colors as text in the hexadecimal format RRGGBB. This text could be, in the worst case, manipulated by hand from some experienced user or system administrator. To get and set the text representation of a color you can use the handy GetString and SetString methods. Under X11 you can use named colors since long. HTML (respectively Internet Explorer) supports them too. Constants and strings are defined for every named color supported by Internet Explorer. Using named colors makes code more readable, because the constant "chocolate" is more understandable than the expression "RGB(0xD2691E)". The name of a color could also be determined as a string data type. It can be used as a means of communication between program and user. Remark: The CColor class does not support palettes and has therefore the greatest use, if windows is be used with more than 256 colors (color depth greater or equal 15/16bit)

Method Overview

CColor Consturctor for COLORREF compatibility. operator COLORREF Conversion operator for COLORREF compatibility. RGB SetRed Sets the red portion of the color (0 - 255). SetGreen Sets the green portion of the color (0 - 255). SetBlue Sets the blue portion of the color (0 - 255). SetRGB Sets the red, green and blue portion of the color in one step. GetRed Gets the red portion of the color (0 - 255). GetGreen Gets the green portion of the color (0 - 255). GetBlue Gets the blue portion of the color (0 - 255). HSL SetHue Sets the hue (0.0 - 360.0, angle in color circle). SetLuminance Sets the luminance (0.0 - 1.0). SetSaturation Set the saturation (0.0 - 1.0). SetHLS Sets the hue, luminance and saturation in one step. GetHue Gets the hue (0.0 - 360.0, angle in color circle). GetLuminance Gets the luminance (0.0 - 1.0). GetSaturation Liefert die Farbsättigung (Wertebereich: 0.0 - 1.0). String SetString Sets the color through extracting it from a string in the hexadecimal format RRGGBB GetString Gets a string which describes the color as a value in the hexadecimal format RRGGBB. Named Colors GetName Gets the user friendly name of the color Farbe. Static GetNameFromIndex Gets the name belonging to a value of ENamedColorIndex . GetColorFromIndex Gets a CColor object, which is initialized with the color represented by a value of ENamedColorIndex GetNumNames Gets the number of named colors. -----------------------------------

Konstanten

CColor::ENamedColor

...

Read article at Internet.com site
Regional Articles
- CColor class Overview Alabama
- CColor class Overview Alaska
- CColor class Overview Arizona
- CColor class Overview Arkansas
- CColor class Overview California
- CColor class Overview Colorado
- CColor class Overview Connecticut
- CColor class Overview DC
- CColor class Overview Delaware
- CColor class Overview Florida
- CColor class Overview Georgia
- CColor class Overview Hawaii
- CColor class Overview Idaho
- CColor class Overview Illinois
- CColor class Overview Indiana
- CColor class Overview Iowa
- CColor class Overview Kansas
- CColor class Overview Kentucky
- CColor class Overview Louisiana
- CColor class Overview Maine
- CColor class Overview Maryland
- CColor class Overview Massachusetts
- CColor class Overview Michigan
- CColor class Overview Minnesota
- CColor class Overview Mississippi
- CColor class Overview Missouri
- CColor class Overview Montana
- CColor class Overview Nebraska
- CColor class Overview Nevada
- CColor class Overview New Hampshire
- CColor class Overview New Jersey
- CColor class Overview New Mexico
- CColor class Overview New York
- CColor class Overview North Carolina
- CColor class Overview North Dakota
- CColor class Overview Ohio
- CColor class Overview Oklahoma
- CColor class Overview Oregon
- CColor class Overview Pennsylvania
- CColor class Overview Rhode Island
- CColor class Overview South Carolina
- CColor class Overview South Dakota
- CColor class Overview Tennessee
- CColor class Overview Texas
- CColor class Overview Utah
- CColor class Overview Vermont
- CColor class Overview Virginia
- CColor class Overview Washington
- CColor class Overview West Virginia
- CColor class Overview Wisconsin
- CColor class Overview Wyoming

Rss   Delicious   Digg   Add To My Yahoo   Add To My Google   Bookmark   Search Plugin

Topics:
Architecture & Design Languages & Tools Project Management Web Services
Database Microsoft & .NET Security Wireless
Java Open Source Techniques XML