Color.FromArgb Color.FromArgb Color.FromArgb Color.FromArgb Method

정의

네 개의 8비트 ARGB 구성 요소(알파, 빨강, 녹색 및 파랑) 값으로 Color 구조체를 만듭니다.Creates a Color structure from the four 8-bit ARGB components (alpha, red, green, and blue) values.

오버로드

FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32)

네 개의 ARGB 구성 요소(알파, 빨강, 녹색 및 파랑) 값으로 Color 구조체를 만듭니다.Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. 이 메서드에서 각각의 구성 요소를 32비트 값으로 전달할 수 있으나, 각 구성 요소의 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.

FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32)

지정된 8비트 값(빨강, 녹색 및 파랑)으로 Color 구조체를 만듭니다.Creates a Color structure from the specified 8-bit color values (red, green, and blue). 암시적으로 알파 값은 255(완전 불투명)입니다.The alpha value is implicitly 255 (fully opaque). 이 메서드에서 각각의 색 구성 요소를 32비트 값으로 전달할 수 있으나, 각 구성 요소의 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits.

FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color)

지정된 Color 구조체에에서 Color 구조체를 만들지만, 알파 값을 새로 지정합니다.Creates a Color structure from the specified Color structure, but with the new specified alpha value. 이 메서드에서 알파 값을 32비트 값으로 전달할 수 있으나, 이 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for the alpha value, the value is limited to 8 bits.

FromArgb(Int32) FromArgb(Int32) FromArgb(Int32) FromArgb(Int32)

32비트 ARGB 값으로 Color 구조체를 만듭니다.Creates a Color structure from a 32-bit ARGB value.

FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32) FromArgb(Int32, Int32, Int32, Int32)

네 개의 ARGB 구성 요소(알파, 빨강, 녹색 및 파랑) 값으로 Color 구조체를 만듭니다.Creates a Color structure from the four ARGB component (alpha, red, green, and blue) values. 이 메서드에서 각각의 구성 요소를 32비트 값으로 전달할 수 있으나, 각 구성 요소의 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for each component, the value of each component is limited to 8 bits.

public:
 static System::Drawing::Color FromArgb(int alpha, int red, int green, int blue);
public static System.Drawing.Color FromArgb (int alpha, int red, int green, int blue);
static member FromArgb : int * int * int * int -> System.Drawing.Color
Public Shared Function FromArgb (alpha As Integer, red As Integer, green As Integer, blue As Integer) As Color

매개 변수

alpha
Int32 Int32 Int32 Int32

알파 구성 요소입니다.The alpha component. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

red
Int32 Int32 Int32 Int32

빨강 구성 요소입니다.The red component. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

green
Int32 Int32 Int32 Int32

녹색 구성 요소입니다.The green component. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

blue
Int32 Int32 Int32 Int32

파랑 구성 요소입니다.The blue component. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

반환

이 메서드가 만드는 Color입니다.The Color that this method creates.

예외

alpha, red, green 또는 blue가 0보다 작거나 255보다 큰 경우alpha, red, green, or blue is less than 0 or greater than 255.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • 세 개 만든 다른 색으로 각 브러시입니다.Creates three brushes, each a different color. Color 브러시를 만드는 데 사용 되는 네 가지 구성 요소 값 (알파, 빨강, 녹색, 파랑)에서 만들어집니다.Each Color structure that is used to create a brush is created from four component values (alpha, red, green, blue).

  • 세 개의 원으로 위치로 가상의 삼각형을 사용 합니다.Uses an imaginary triangle to position three circles.

  • 각 원은 대 한 다른 브러시를 사용 하 여 삼각형의 꼭지점을 중심으로 각 세 가지 겹치는 원을 그립니다.Paints three overlapping circles, each centered on one vertex of the triangle, using a different brush for each circle.

void FromArgb1( PaintEventArgs^ e )
{
   Graphics^ g = e->Graphics;

   // Transparent red, green, and blue brushes.
   SolidBrush^ trnsRedBrush = gcnew SolidBrush( Color::FromArgb( 120, 255, 0, 0 ) );
   SolidBrush^ trnsGreenBrush = gcnew SolidBrush( Color::FromArgb( 120, 0, 255, 0 ) );
   SolidBrush^ trnsBlueBrush = gcnew SolidBrush( Color::FromArgb( 120, 0, 0, 255 ) );

   // Base and height of the triangle that is used to position the
   // circles. Each vertex of the triangle is at the center of one of the
   // 3 circles. The base is equal to the diameter of the circles.
   float triBase = 100;
   float triHeight = (float)Math::Sqrt( 3 * (triBase * triBase) / 4 );

   // Coordinates of first circle's bounding rectangle.
   float x1 = 40;
   float y1 = 40;

   // Fill 3 over-lapping circles. Each circle is a different color.
   g->FillEllipse( trnsRedBrush, x1, y1, 2 * triHeight, 2 * triHeight );
   g->FillEllipse( trnsGreenBrush, x1 + triBase / 2, y1 + triHeight, 2 * triHeight, 2 * triHeight );
   g->FillEllipse( trnsBlueBrush, x1 + triBase, y1, 2 * triHeight, 2 * triHeight );
}
public void FromArgb1(PaintEventArgs e)
{
    Graphics     g = e.Graphics;
             
    // Transparent red, green, and blue brushes.
    SolidBrush trnsRedBrush = new SolidBrush(Color.FromArgb(120, 255, 0, 0));
    SolidBrush trnsGreenBrush = new SolidBrush(Color.FromArgb(120, 0, 255, 0));
    SolidBrush trnsBlueBrush = new SolidBrush(Color.FromArgb(120, 0, 0, 255));
             
    // Base and height of the triangle that is used to position the
    // circles. Each vertex of the triangle is at the center of one of the
    // 3 circles. The base is equal to the diameter of the circles.
    float   triBase = 100;
    float   triHeight = (float)Math.Sqrt(3*(triBase*triBase)/4);
             
    // Coordinates of first circle's bounding rectangle.
    float   x1 = 40;
    float   y1 = 40;
             
    // Fill 3 over-lapping circles. Each circle is a different color.
    g.FillEllipse(trnsRedBrush, x1, y1, 2*triHeight, 2*triHeight);
    g.FillEllipse(trnsGreenBrush, x1 + triBase/2, y1 + triHeight,
        2*triHeight, 2*triHeight);
    g.FillEllipse(trnsBlueBrush, x1 + triBase, y1, 2*triHeight, 2*triHeight);
}
Public Sub FromArgb1(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    ' Transparent red, green, and blue brushes.
    Dim trnsRedBrush As New SolidBrush(Color.FromArgb(120, 255, 0, 0))
    Dim trnsGreenBrush As New SolidBrush(Color.FromArgb(120, 0, _
    255, 0))
    Dim trnsBlueBrush As New SolidBrush(Color.FromArgb(120, 0, 0, 255))

    ' Base and height of the triangle that is used to position the
    ' circles. Each vertex of the triangle is at the center of one of
    ' the 3 circles. The base is equal to the diameter of the circle.
    Dim triBase As Single = 100
    Dim triHeight As Single = CSng(Math.Sqrt((3 * (triBase * _
    triBase) / 4)))

    ' Coordinates of first circle's bounding rectangle.
    Dim x1 As Single = 40
    Dim y1 As Single = 40

    ' Fill 3 over-lapping circles. Each circle is a different color.
    g.FillEllipse(trnsRedBrush, x1, y1, 2 * triHeight, 2 * triHeight)
    g.FillEllipse(trnsGreenBrush, x1 + triBase / 2, y1 + triHeight, _
    2 * triHeight, 2 * triHeight)
    g.FillEllipse(trnsBlueBrush, x1 + triBase, y1, 2 * triHeight, _
    2 * triHeight)
End Sub

설명

불투명 한 색을 만들려면 설정 alpha 255입니다.To create an opaque color, set alpha to 255. 반투명 색을 만들려면 설정 alpha 1에서 254 까지의 값으로.To create a semitransparent color, set alpha to any value from 1 through 254.

FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32) FromArgb(Int32, Int32, Int32)

지정된 8비트 값(빨강, 녹색 및 파랑)으로 Color 구조체를 만듭니다.Creates a Color structure from the specified 8-bit color values (red, green, and blue). 암시적으로 알파 값은 255(완전 불투명)입니다.The alpha value is implicitly 255 (fully opaque). 이 메서드에서 각각의 색 구성 요소를 32비트 값으로 전달할 수 있으나, 각 구성 요소의 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for each color component, the value of each component is limited to 8 bits.

public:
 static System::Drawing::Color FromArgb(int red, int green, int blue);
public static System.Drawing.Color FromArgb (int red, int green, int blue);
static member FromArgb : int * int * int -> System.Drawing.Color
Public Shared Function FromArgb (red As Integer, green As Integer, blue As Integer) As Color

매개 변수

red
Int32 Int32 Int32 Int32

Color의 빨강 구성 요소 값입니다.The red component value for the new Color. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

green
Int32 Int32 Int32 Int32

Color의 녹색 구성 요소 값입니다.The green component value for the new Color. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

blue
Int32 Int32 Int32 Int32

Color의 파랑 구성 요소 값입니다.The blue component value for the new Color. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

반환

이 메서드가 만드는 Color입니다.The Color that this method creates.

예외

red, green 또는 blue가 0보다 작거나 255보다 큰 경우red, green, or blue is less than 0 or greater than 255.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  1. 만듭니다 Color 세 개의 색 구성 요소 값 (빨강, 녹색, 파랑) 구조입니다.Creates Color structures from the three color component values (red, green, blue). 세 가지 Color 각 기본 색에 대 한 구조는 생성 합니다.Three Color structures are created, one for each primary color.

  2. 색의 알파 값을 변경 하는 알파 값의 범위를 반복 합니다.Iterates through a range of alpha values, changing the alpha value of a color.

  3. 각 반복 하는 동안 수정 된 색으로 브러시의 색을 설정 하 고 색을 표시 하는 사각형을 그립니다.During each iteration, sets the color of a brush to the modified color and paints a rectangle to show the color.

  4. 각 기본 색에 대 한 2-3 단계를 반복합니다.Repeats steps 2 and 3 for each primary color.

알파 값은 완전히 불투명 하 고 사각형 겹치기 때문에 색 조합을 효과입니다.The alpha value is never fully opaque and the rectangles overlap so you get color-combination effects.

void FromArgb2( PaintEventArgs^ e )
{
   Graphics^ g = e->Graphics;

   // Opaque colors (alpha value defaults to 255 -- max value).
   Color red = Color::FromArgb( 255, 0, 0 );
   Color green = Color::FromArgb( 0, 255, 0 );
   Color blue = Color::FromArgb( 0, 0, 255 );

   // Solid brush initialized to red.
   SolidBrush^ myBrush = gcnew SolidBrush( red );
   int alpha;

   // x coordinate of first red rectangle
   int x = 50;

   // y coordinate of first red rectangle
   int y = 50;

   // Fill rectangles with red, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, red );
      g->FillRectangle( myBrush, x, y, 50, 100 );
      g->FillRectangle( myBrush, x, y + 250, 50, 50 );
      x += 50;
   }
   x = 50;

   // y coordinate of first green rectangle.
   y += 50;

   // Fill rectangles with green, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, green );
      g->FillRectangle( myBrush, x, y, 50, 150 );
      x += 50;
   }
   x = 50;

   // y coordinate of first blue rectangle.
   y += 100;

   // Fill rectangles with blue, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, blue );
      g->FillRectangle( myBrush, x, y, 50, 150 );
      x += 50;
   }
}
public void FromArgb2(PaintEventArgs e)
{
    Graphics     g = e.Graphics;
             
    // Opaque colors (alpha value defaults to 255 -- max value).
    Color red = Color.FromArgb(255, 0, 0);
    Color green = Color.FromArgb(0, 255, 0);
    Color blue = Color.FromArgb(0, 0, 255);
             
    // Solid brush initialized to red.
    SolidBrush  myBrush = new SolidBrush(red);
    int alpha;

    // x coordinate of first red rectangle
    int x = 50;         
    
    // y coordinate of first red rectangle
    int y = 50;         
                   
    // Fill rectangles with red, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, red);
        g.FillRectangle(myBrush, x, y, 50, 100);
        g.FillRectangle(myBrush, x, y + 250, 50, 50);
        x += 50;
    }
    // x coordinate of first green rectangle.
    x = 50;             
    
    // y coordinate of first green rectangle.
    y += 50;            
                      
    // Fill rectangles with green, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, green);
        g.FillRectangle(myBrush, x, y, 50, 150);
        x += 50;
    }
    // x coordinate of first blue rectangle.
    x = 50;             
    
    // y coordinate of first blue rectangle.
    y += 100;           
             
    // Fill rectangles with blue, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, blue);
        g.FillRectangle(myBrush, x, y, 50, 150);
        x += 50;
    }
}
Public Sub FromArgb2(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    ' Opaque colors (alpha value defaults to 255 -- max value).
    Dim red As Color = Color.FromArgb(255, 0, 0)
    Dim green As Color = Color.FromArgb(0, 255, 0)
    Dim blue As Color = Color.FromArgb(0, 0, 255)

    ' Solid brush initialized to red.
    Dim myBrush As New SolidBrush(red)
    Dim alpha As Integer

    ' x coordinate of first red rectangle.
    Dim x As Integer = 50

    ' y coordinate of first red rectangle.
    Dim y As Integer = 50

    ' Fill rectangles with red, varying the alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, red)
        g.FillRectangle(myBrush, x, y, 50, 100)
        g.FillRectangle(myBrush, x, y + 250, 50, 50)
        x += 50
    Next alpha

    ' x coordinate of first green rectangle.
    x = 50

    ' y coordinate of first green rectangle.
    y += 50


    ' Fill rectangles with green, varying alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, green)
        g.FillRectangle(myBrush, x, y, 50, 150)
        x += 50
    Next alpha

    ' x coordinate of first blue rectangle.
    x = 50

    ' y coordinate of first blue rectangle.
    y += 100

    ' Fill rectangles with blue, varying alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, blue)
        g.FillRectangle(myBrush, x, y, 50, 150)
        x += 50
    Next alpha
End Sub

FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color) FromArgb(Int32, Color)

지정된 Color 구조체에에서 Color 구조체를 만들지만, 알파 값을 새로 지정합니다.Creates a Color structure from the specified Color structure, but with the new specified alpha value. 이 메서드에서 알파 값을 32비트 값으로 전달할 수 있으나, 이 값은 8비트로 제한됩니다.Although this method allows a 32-bit value to be passed for the alpha value, the value is limited to 8 bits.

public:
 static System::Drawing::Color FromArgb(int alpha, System::Drawing::Color baseColor);
public static System.Drawing.Color FromArgb (int alpha, System.Drawing.Color baseColor);
static member FromArgb : int * System.Drawing.Color -> System.Drawing.Color
Public Shared Function FromArgb (alpha As Integer, baseColor As Color) As Color

매개 변수

alpha
Int32 Int32 Int32 Int32

Color의 알파 값입니다.The alpha value for the new Color. 유효한 값은 0부터 255까지입니다.Valid values are 0 through 255.

baseColor
Color Color Color Color

Color을 만들 Color입니다.The Color from which to create the new Color.

반환

이 메서드가 만드는 Color입니다.The Color that this method creates.

예외

alpha가 0보다 작거나 255보다 큽니다.alpha is less than 0 or greater than 255.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  1. 만듭니다 Color 세 개의 색 구성 요소 값 (빨강, 녹색, 파랑) 구조입니다.Creates Color structures from the three color component values (red, green, blue). 세 가지 Color 각 기본 색에 대 한 구조는 생성 합니다.Three Color structures are created, one for each primary color.

  2. 색의 알파 값을 변경 하는 알파 값의 범위를 반복 합니다.Iterates through a range of alpha values, changing the alpha value of a color.

  3. 각 반복 하는 동안 수정 된 색으로 브러시의 색을 설정 하 고 색을 표시 하는 사각형을 그립니다.During each iteration, sets the color of a brush to the modified color and paints a rectangle to show the color.

  4. 각 기본 색에 대 한 2-3 단계를 반복합니다.Repeats steps 2 and 3 for each primary color.

알파 값은 완전히 불투명 하 고 사각형 겹치기 때문에 색 조합을 효과입니다.The alpha value is never fully opaque and the rectangles overlap so you get color-combination effects.

void FromArgb3( PaintEventArgs^ e )
{
   Graphics^ g = e->Graphics;

   // Opaque colors (alpha value defaults to 255 -- max value).
   Color red = Color::FromArgb( 255, 0, 0 );
   Color green = Color::FromArgb( 0, 255, 0 );
   Color blue = Color::FromArgb( 0, 0, 255 );

   // Solid brush initialized to red.
   SolidBrush^ myBrush = gcnew SolidBrush( red );
   int alpha;

   // x coordinate of first red rectangle
   int x = 50;

   // y coordinate of first red rectangle
   int y = 50;

   // Fill rectangles with red, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, red );
      g->FillRectangle( myBrush, x, y, 50, 100 );
      g->FillRectangle( myBrush, x, y + 250, 50, 50 );
      x += 50;
   }
   x = 50;

   // y coordinate of first green rectangle
   y += 50;

   // Fill rectangles with green, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, green );
      g->FillRectangle( myBrush, x, y, 50, 150 );
      x += 50;
   }
   x = 50;

   // y coordinate of first blue rectangle
   y += 100;

   // Fill rectangles with blue, varying the alpha value from 25 to 250.
   for ( alpha = 25; alpha <= 250; alpha += 25 )
   {
      myBrush->Color = Color::FromArgb( alpha, blue );
      g->FillRectangle( myBrush, x, y, 50, 150 );
      x += 50;
   }
}
public void FromArgb3(PaintEventArgs e)
{
    Graphics     g = e.Graphics;
             
    // Opaque colors (alpha value defaults to 255 -- max value).
    Color red = Color.FromArgb(255, 0, 0);
    Color green = Color.FromArgb(0, 255, 0);
    Color blue = Color.FromArgb(0, 0, 255);
             
    // Solid brush initialized to red.
    SolidBrush  myBrush = new SolidBrush(red);
    int alpha;
    
    // x coordinate of first red rectangle
    int x = 50;         
    
    // y coordinate of first red rectangle
    int y = 50;         
    
    // Fill rectangles with red, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, red);
        g.FillRectangle(myBrush, x, y, 50, 100);
        g.FillRectangle(myBrush, x, y + 250, 50, 50);
        x += 50;
    }
    // x coordinate of first green rectangle
    x = 50;             
    
    // y coordinate of first green rectangle
    y += 50;            
    
    // Fill rectangles with green, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, green);
        g.FillRectangle(myBrush, x, y, 50, 150);
        x += 50;
    }
    // x coordinate of first blue rectangle.
    x = 50; 
    
     // y coordinate of first blue rectangle
    y += 100;           
   
             
    // Fill rectangles with blue, varying the alpha value from 25 to 250.
    for (alpha = 25; alpha <= 250; alpha += 25)
    {
        myBrush.Color = Color.FromArgb(alpha, blue);
        g.FillRectangle(myBrush, x, y, 50, 150);
        x += 50;
    }
}
Public Sub FromArgb3(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    ' Opaque colors (alpha value defaults to 255 -- max value).
    Dim red As Color = Color.FromArgb(255, 0, 0)
    Dim green As Color = Color.FromArgb(0, 255, 0)
    Dim blue As Color = Color.FromArgb(0, 0, 255)

    ' Solid brush initialized to red.
    Dim myBrush As New SolidBrush(red)
    Dim alpha As Integer

    ' x coordinate of first red rectangle.
    Dim x As Integer = 50

    ' y coordinate of first red rectangle.
    Dim y As Integer = 50

    ' Fill rectangles with red, varying the alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, red)
        g.FillRectangle(myBrush, x, y, 50, 100)
        g.FillRectangle(myBrush, x, y + 250, 50, 50)
        x += 50
    Next alpha

    ' x coordinate of first green rectangle.
    x = 50

    ' y coordinate of first green rectangle.
    y += 50

    ' Fill rectangles with green, varying alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, green)
        g.FillRectangle(myBrush, x, y, 50, 150)
        x += 50
    Next alpha

    ' x coordinate of first blue rectangle.
    x = 50

    ' y coordinate of first blue rectangle.
    y += 100

    ' Fill rectangles with blue, varying alpha value from 25 to 250.
    For alpha = 25 To 250 Step 25
        myBrush.Color = Color.FromArgb(alpha, blue)
        g.FillRectangle(myBrush, x, y, 50, 150)
        x += 50
    Next alpha
End Sub

설명

불투명 한 색을 만들려면 설정 alpha 255입니다.To create an opaque color, set alpha to 255. 반투명 색을 만들려면 설정 alpha 1에서 254 까지의 값으로.To create a semitransparent color, set alpha to any value from 1 through 254.

FromArgb(Int32) FromArgb(Int32) FromArgb(Int32) FromArgb(Int32)

32비트 ARGB 값으로 Color 구조체를 만듭니다.Creates a Color structure from a 32-bit ARGB value.

public:
 static System::Drawing::Color FromArgb(int argb);
public static System.Drawing.Color FromArgb (int argb);
static member FromArgb : int -> System.Drawing.Color
Public Shared Function FromArgb (argb As Integer) As Color

매개 변수

argb
Int32 Int32 Int32 Int32

32비트ARGB 값을 지정하는 값입니다.A value specifying the 32-bit ARGB value.

반환

이 메서드가 만드는 Color 구조체를 반환합니다.The Color structure that this method creates.

예제

다음 코드 예제는 Windows Forms에서 사용 하도록 설계 되었으며 필요 PaintEventArgs e의 매개 변수는 Paint 이벤트 처리기입니다.The following code example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. 이 코드에서는 다음 작업을 수행합니다.The code performs the following actions:

  • 세 개 만든 다른 색으로 각 브러시입니다.Creates three brushes, each a different color. Color 브러시를 만드는 데 사용 되는 32 비트 ARGB 값에서 생성 됩니다.Each Color structure that is used to create a brush is created from a 32-bit ARGB value.

  • 세 개의 원으로 위치로 가상의 삼각형을 사용 합니다.Uses an imaginary triangle to position three circles.

  • 각 원은 대 한 다른 브러시를 사용 하 여 삼각형의 꼭지점을 중심으로 각 세 가지 겹치는 원을 그립니다.Paints three overlapping circles, each centered on one vertex of the triangle, using a different brush for each circle.

void FromArgb4( PaintEventArgs^ e )
{
   Graphics^ g = e->Graphics;

   // Transparent red, green, and blue brushes.
   SolidBrush^ trnsRedBrush = gcnew SolidBrush( Color::FromArgb( 0x78FF0000 ) );
   SolidBrush^ trnsGreenBrush = gcnew SolidBrush( Color::FromArgb( 0x7800FF00 ) );
   SolidBrush^ trnsBlueBrush = gcnew SolidBrush( Color::FromArgb( 0x780000FF ) );

   // Base and height of the triangle that is used to position the
   // circles. Each vertex of the triangle is at the center of one of the
   // 3 circles. The base is equal to the diameter of the circles.
   float triBase = 100;
   float triHeight = (float)Math::Sqrt( 3 * (triBase * triBase) / 4 );

   // coordinates of first circle's bounding rectangle.
   float x1 = 40;
   float y1 = 40;

   // Fill 3 over-lapping circles. Each circle is a different color.
   g->FillEllipse( trnsRedBrush, x1, y1, 2 * triHeight, 2 * triHeight );
   g->FillEllipse( trnsGreenBrush, x1 + triBase / 2, y1 + triHeight, 2 * triHeight, 2 * triHeight );
   g->FillEllipse( trnsBlueBrush, x1 + triBase, y1, 2 * triHeight, 2 * triHeight );
}
public void FromArgb4(PaintEventArgs e)
{
    Graphics     g = e.Graphics;
             
    // Transparent red, green, and blue brushes.
    SolidBrush trnsRedBrush = new SolidBrush(Color.FromArgb(0x78FF0000));
    SolidBrush trnsGreenBrush = new SolidBrush(Color.FromArgb(0x7800FF00));
    SolidBrush trnsBlueBrush = new SolidBrush(Color.FromArgb(0x780000FF));
             
    // Base and height of the triangle that is used to position the
    // circles. Each vertex of the triangle is at the center of one of the
    // 3 circles. The base is equal to the diameter of the circles.
    float   triBase = 100;
    float   triHeight = (float)Math.Sqrt(3*(triBase*triBase)/4);
             
    // coordinates of first circle's bounding rectangle.
    float   x1 = 40;
    float   y1 = 40;
             
    // Fill 3 over-lapping circles. Each circle is a different color.
    g.FillEllipse(trnsRedBrush, x1, y1, 2*triHeight, 2*triHeight);
    g.FillEllipse(trnsGreenBrush, x1 + triBase/2, y1 + triHeight,
        2*triHeight, 2*triHeight);
    g.FillEllipse(trnsBlueBrush, x1 + triBase, y1, 2*triHeight, 2*triHeight);
}
Public Sub FromArgb4(ByVal e As PaintEventArgs)
    Dim g As Graphics = e.Graphics

    ' Transparent red, green, and blue brushes.
    Dim trnsRedBrush As New SolidBrush(Color.FromArgb(&H78FF0000))
    Dim trnsGreenBrush As New SolidBrush(Color.FromArgb(&H7800FF00))
    Dim trnsBlueBrush As New SolidBrush(Color.FromArgb(&H780000FF))

    ' Base and height of the triangle that is used to position the
    ' circles. Each vertex of the triangle is at the center of one of
    ' the 3 circles. The base is equal to the diameter of the circle.
    Dim triBase As Single = 100
    Dim triHeight As Single = CSng(Math.Sqrt((3 * (triBase * _
    triBase) / 4)))

    ' Coordinates of first circle
    's bounding rectangle.
    Dim x1 As Single = 40
    Dim y1 As Single = 40

    ' Fill 3 over-lapping circles. Each circle is a different color.
    g.FillEllipse(trnsRedBrush, x1, y1, 2 * triHeight, 2 * triHeight)
    g.FillEllipse(trnsGreenBrush, x1 + triBase / 2, y1 + triHeight, _
    2 * triHeight, 2 * triHeight)
    g.FillEllipse(trnsBlueBrush, x1 + triBase, y1, 2 * triHeight, _
    2 * triHeight)
End Sub

설명

바이트-32 비트 ARGB 값의 순서가 AARRGGBB 합니다.The byte-ordering of the 32-bit ARGB value is AARRGGBB. AA를 나타내는 최상위 바이트 msb (최상위)은 알파 구성 요소 값입니다.The most significant byte (MSB), represented by AA, is the alpha component value. 두 번째, 세 번째 및 네 번째 바이트, RR, GG, BB를 각각 나타내는 빨강, 녹색 및 파랑은 각각.The second, third, and fourth bytes, represented by RR, GG, and BB, respectively, are the color components red, green, and blue, respectively.

적용 대상