Color.A 属性


获取此 Color 结构的 alpha 组件值。Gets the alpha component value of this Color structure.

 property System::Byte A { System::Byte get(); };
public byte A { get; }
member this.A : byte
Public ReadOnly Property A As Byte


Color 的 alpha 分量值。The alpha component value of this Color.


下面的代码示例演示 ColorImplicit 成员的 ARGB 属性。The following code example demonstrates the A, R, G, and B properties of a Color, and the Implicit member.

此示例旨在与 Windows 窗体一起使用。This example is designed to be used with a Windows Form. 将代码粘贴到窗体中,并从窗体的 Paint 事件处理方法中调用 ShowPropertiesOfSlateBlue 方法,并将 e 作为 PaintEventArgs传递。Paste the code into the form and call the ShowPropertiesOfSlateBlue method from the form's Paint event-handling method, passing e as PaintEventArgs.

void ShowPropertiesOfSlateBlue( PaintEventArgs^ e )
   Color slateBlue = Color::FromName( "SlateBlue" );
   Byte g = slateBlue.G;
   Byte b = slateBlue.B;
   Byte r = slateBlue.R;
   Byte a = slateBlue.A;
   array<Object^>^temp0 = {a,r,g,b};
   String^ text = String::Format( "Slate Blue has these ARGB values: Alpha:{0}, "
   "red:{1}, green: {2}, blue {3}", temp0 );
   e->Graphics->DrawString( text, gcnew System::Drawing::Font( this->Font,FontStyle::Italic ), gcnew SolidBrush( slateBlue ), RectangleF(PointF(0.0F,0.0F),this->Size) );
private void ShowPropertiesOfSlateBlue(PaintEventArgs e)
    Color slateBlue = Color.FromName("SlateBlue");
    byte g = slateBlue.G;
    byte b = slateBlue.B;
    byte r = slateBlue.R;
    byte a = slateBlue.A;
    string text = String.Format("Slate Blue has these ARGB values: Alpha:{0}, " +
        "red:{1}, green: {2}, blue {3}", new object[]{a, r, g, b});
        new Font(this.Font, FontStyle.Italic), 
        new SolidBrush(slateBlue), 
        new RectangleF(new PointF(0.0F, 0.0F), this.Size));
Private Sub ShowPropertiesOfSlateBlue(ByVal e As PaintEventArgs)
    Dim slateBlue As Color = Color.FromName("SlateBlue")
    Dim g As Byte = slateBlue.G
    Dim b As Byte = slateBlue.B
    Dim r As Byte = slateBlue.R
    Dim a As Byte = slateBlue.A
    Dim text As String = _
    String.Format("Slate Blue has these ARGB values: Alpha:{0}, " _
       & "red:{1}, green: {2}, blue {3}", New Object() {a, r, g, b})
    e.Graphics.DrawString(text, New Font(Me.Font, FontStyle.Italic), _
        New SolidBrush(slateBlue), _
        New RectangleF(New PointF(0.0F, 0.0F), _
End Sub


每个像素的颜色表示为32位数字:8位,分别用于 alpha、红色、绿色和蓝色(ARGB)。The color of each pixel is represented as a 32-bit number: 8 bits each for alpha, red, green, and blue (ARGB). Alpha 分量指定颜色的透明度:0表示完全透明,255表示完全不透明。The alpha component specifies the transparency of the color: 0 is fully transparent, and 255 is fully opaque. 同样,A 值255表示不透明颜色。Likewise, an A value of 255 represents an opaque color. 1到254之间的 A 值表示半透明颜色。An A value from 1 through 254 represents a semitransparent color. A 方法255,颜色变得更不透明。The color becomes more opaque as A approaches 255.