Color.G 속성
정의
public:
property System::Byte G { System::Byte get(); };
public byte G { get; }
member this.G : byte
Public ReadOnly Property G As Byte
속성 값
Color의 녹색 구성 요소 값입니다.The green component value of this Color.
예제
다음 코드 예제에서는, A R G B 및 멤버의,, 및 속성을 Color 보여 줍니다 Implicit .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. 폼에 코드를 붙여넣고 ShowPropertiesOfSlateBlue
폼의 Paint 이벤트 처리 메서드에서를로 전달 하 여 메서드를 호출 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});
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 비트 숫자로 표시 됩니다. 각각 알파, 빨강, 녹색 및 파랑 (ARGB)의 8 비트입니다.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. 마찬가지로 G 는 0에서 255 사이의 값 이며, 0은 녹색 및 255을 모두 녹색으로 표시 합니다.Likewise, G is a value from 0 to 255 with 0 representing no green and 255 representing fully green.