Color.B 屬性

定義

取得這個 Color 結構的藍色元件值。Gets the blue component value of this Color structure.

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

屬性值

這個 Color 的藍色元件值。The blue 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 Form 搭配使用。This example is designed to be used with a Windows Form. 將程式碼貼入表單,並從表單的 Paint 事件處理方法呼叫 ShowPropertiesOfSlateBlue 方法,傳遞 e 作為 PaintEventArgsPaste 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});
    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

備註

每個圖元的色彩都會以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). 四個元件中的每個都是從0到255的數位,0代表沒有濃度,而255代表完整的濃度。Each of the four components is a number from 0 through 255, with 0 representing no intensity and 255 representing full intensity. 同樣地,B 是0到255的值,0代表沒有藍色,而255代表完全藍色。Likewise, B is a value from 0 to 255 with 0 representing no blue and 255 representing fully blue.

適用於