Color.GetR method
Applies to: desktop apps only
The Color::GetR method gets the red component of this Color object.
Syntax
BYTE GetR();
Parameters
This method has no parameters.
Return value
Type:
Type: BYTE
This method returns the red component of this color.
Examples
The following example creates a Color object, gets the red component of the color, and creates a second Color object that uses the same red component. It then fills a rectangle by using a Brush object based on the second color.
VOID Example_GetR(HDC hdc)
{
Graphics graphics(hdc);
// Create a Color object with a red component value of 255.
Color firstColor(0, 255, 255, 255);
// Get the red component value of firstColor.
int red = firstColor.GetR();
// Create a new Color object with the same red component value as firstColor.
Color secondColor(255, red, 0, 0);
// Create a SolidBrush object with secondColor, and use it to fill a rectangle.
SolidBrush redBrush(secondColor);
graphics.FillRectangle(&redBrush, Rect(0, 0, 100, 100));
}
Requirements
|
Minimum supported client | Windows XP, Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Product | GDI+ 1.0 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Color
- Color::GetAlpha
- Color::GetB
- Color::GetBlue
- Color::GetG
- Color::GetGreen
- Color::GetR
- Color::GetRed
- Color::GetValue
Send comments about this topic to Microsoft
Build date: 3/6/2012