Color Decoding |
|
Colors and the API Functions |
A color is a long integer that is made of a red, a green, and a blue values. The Win32 API provides three valuable functions that allow you to retrieve these values if you know the integral value of a color. Suppose you know the complete integral value of a color. To retrieve its Red value, you can use the GetRValue() function. In the same way, you can use the GetGValue() and the GetBValue() functions to get the Green and the Blue values of the color. These functions can be applied whether the color value is in decimal or hexadecimal value. Here is an example:
|
//--------------------------------------------------------------------------- void __fastcall TForm1::Button1Click(TObject *Sender) { long Clr = Edit1->Text.ToInt(); int R = GetRValue(Clr); int G = GetGValue(Clr); int B = GetBValue(Clr); } //--------------------------------------------------------------------------- In VCL applications, the GetRValue(), GetGValue(), and GetBValue() functions can be applied on any valid TColor value.
|
|
Copyright © 2003-2007 FunctionX, Inc. |
|