GetG
Collapse the table of content
Expand the table of content

Color.GetG method

Applies to: desktop apps only

The Color::GetG method gets the green component of this Color object.

Syntax

BYTE GetG();

Parameters

This method has no parameters.

Return value

Type:

Type: BYTE

This method returns the green component of this color.

Examples

The following example creates a Color object, gets the green component of the color, and creates a second Color object that uses the same green component. It then fills a rectangle by using a Brush object based on the second color.


VOID Example_GetG(HDC hdc)
{
   Graphics graphics(hdc);

   // Create a Color object with a blue component value of 255.
   Color firstColor(0, 255, 255, 255);

   // Get the blue component value of firstColor.
   int green = firstColor.GetG();

   // Create a new Color object with the same blue component value as firstColor.
   Color secondColor(255, 0, green, 0);

   // Create a SolidBrush object with secondColor, and use it to fill a rectangle.
   SolidBrush greenBrush(secondColor);
   graphics.FillRectangle(&greenBrush, 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

Gdipluscolor.h (include Gdiplus.h)

Library

Gdiplus.lib

DLL

Gdiplus.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

Community Additions

ADD
Show:
© 2016 Microsoft