Color.GetAlpha method
Applies to: desktop apps only
The Color::GetAlpha method gets the alpha component of this Color object.
Syntax
BYTE GetAlpha();
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_GetAlpha(HDC hdc)
{
Graphics graphics(hdc);
// Create a Color object with an alpha component value of 128.
Color firstColor(128, 255, 0, 0);
// Get the alpha value of firstColor.
int alpha = firstColor.GetAlpha();
// Create a new Color object with the same alpha component value as firstColor.
Color secondColor(alpha, 0, 0, 255);
// Create a SolidBrush object with secondColor, and use it to fill a rectangle.
SolidBrush alphaBrush(secondColor);
graphics.FillRectangle(&alphaBrush, 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