Export (0) Print
Expand All

Color.GetA method

Applies to: desktop apps only

The Color::GetA method gets the alpha component of this Color object.

Syntax

BYTE GetA();

Parameters

This method has no parameters.

Return value

Type:

Type: BYTE

This method returns the alpha component of this color.

Examples

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


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

   // Create a Color object with an alpha value of 128.
   Color firstColor(128, 255, 0, 0);

   // Get the alpha value of firstColor.
   char alpha = firstColor.GetA();

   // Create a second Color object with an alpha value taken from firstColor.
   Color secondColor(alpha, 0, 0, 255);

   // Create a pen using secondColor and use it to draw a line.
   Pen pen((secondColor), 20);    
   graphics.DrawLine(&pen, 50, 50, 200, 50);
}

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:
© 2014 Microsoft