Color.A Proprietà

Definizione

Ottiene il valore del componente alfa di questa struttura Color.

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

Valore della proprietà

Valore del componente alfa di questo oggetto Color.

Esempio

Nell'esempio di codice seguente vengono illustrate le Aproprietà , R, Ge B di un Coloroggetto e il Implicit membro .

Questo esempio è progettato per essere usato con Windows Form. Incollare il codice nel form e chiamare il ShowPropertiesOfSlateBlue metodo dal metodo di gestione degli eventi del Paint modulo, passando e come 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});
    e.Graphics.DrawString(text, 
        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), _
        Size.op_Implicit(Me.Size)))
End Sub

Commenti

Il colore di ogni pixel è rappresentato come numero a 32 bit: 8 bit per alfa, rosso, verde e blu (ARGB). Il componente alfa specifica la trasparenza del colore: 0 è completamente trasparente e 255 è completamente opaco. Analogamente, un A valore pari a 255 rappresenta un colore opaco. Un A valore compreso tra 1 e 254 rappresenta un colore semitrasparente. Il colore diventa più opaco man mano che A si avvicina a 255.

Si applica a