Color.FromArgb Méthode

Définition

Crée une structure Color à partir des valeurs des quatre composants ARVB 8 bits (alpha, rouge, vert et bleu).

Surcharges

FromArgb(Int32, Int32, Int32, Int32)

Crée une structure Color à partir des valeurs des quatre composants ARVB (alpha, rouge, vert et bleu). Bien que cette méthode permette de passer une valeur 32 bits pour chaque composant, leur valeur est limitée à 8 bits.

FromArgb(Int32, Int32, Int32)

Crée une structure Color à partir des valeurs de couleurs 8 bits spécifiées (rouge, vert et bleu). La valeur alpha est implicitement égale à 255 (entièrement opaque). Bien que cette méthode permette de passer une valeur 32 bits pour chaque composant de couleur, leur valeur est limitée à 8 bits.

FromArgb(Int32, Color)

Crée une structure Color à partir de la structure Color spécifiée, mais avec la nouvelle valeur alpha spécifiée. Bien que cette méthode permette de passer une valeur 32 bits pour la valeur alpha, cette dernière est limitée à 8 bits.

FromArgb(Int32)

Crée une structure Color à partir d'une valeur ARVB 32 bits.

FromArgb(Int32, Int32, Int32, Int32)

Source:
Color.cs
Source:
Color.cs
Source:
Color.cs

Crée une structure Color à partir des valeurs des quatre composants ARVB (alpha, rouge, vert et bleu). Bien que cette méthode permette de passer une valeur 32 bits pour chaque composant, leur valeur est limitée à 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

Paramètres

alpha
Int32

Composant alpha. Les valeurs autorisées sont comprises entre 0 et 255.

red
Int32

Composant rouge. Les valeurs autorisées sont comprises entre 0 et 255.

green
Int32

Composant vert. Les valeurs autorisées sont comprises entre 0 et 255.

blue
Int32

Composant bleu. Les valeurs autorisées sont comprises entre 0 et 255.

Retours

Color créé par cette méthode.

Exceptions

alpha, red, green ou blue est inférieur à 0 ou supérieur à 255.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

  • Crée trois pinceaux, chacun d’une couleur différente. Chaque Color structure utilisée pour créer un pinceau est créée à partir de quatre valeurs de composants (alpha, rouge, vert, bleu).

  • Utilise un triangle imaginaire pour positionner trois cercles.

  • Peint trois cercles qui se chevauchent, chacun centré sur un sommet du triangle, à l’aide d’un pinceau différent pour chaque cercle.

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

Remarques

Pour créer une couleur opaque, définissez sur alpha 255. Pour créer une couleur semi-transparence, définissez alpha sur n’importe quelle valeur comprise entre 1 et 254.

S’applique à

FromArgb(Int32, Int32, Int32)

Source:
Color.cs
Source:
Color.cs
Source:
Color.cs

Crée une structure Color à partir des valeurs de couleurs 8 bits spécifiées (rouge, vert et bleu). La valeur alpha est implicitement égale à 255 (entièrement opaque). Bien que cette méthode permette de passer une valeur 32 bits pour chaque composant de couleur, leur valeur est limitée à 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

Paramètres

red
Int32

Valeur du composant rouge du nouveau Color. Les valeurs autorisées sont comprises entre 0 et 255.

green
Int32

Valeur du composant vert du nouveau Color. Les valeurs autorisées sont comprises entre 0 et 255.

blue
Int32

Valeur du composant bleu du nouveau Color. Les valeurs autorisées sont comprises entre 0 et 255.

Retours

Color créé par cette méthode.

Exceptions

red, green ou blue est inférieur à 0 ou supérieur à 255.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

  1. Crée des Color structures à partir des trois valeurs de composant de couleur (rouge, vert, bleu). Trois Color structures sont créées, une pour chaque couleur primaire.

  2. Itère au sein d’une plage de valeurs alpha, en modifiant la valeur alpha d’une couleur.

  3. Au cours de chaque itération, définit la couleur d’un pinceau sur la couleur modifiée et peint un rectangle pour afficher la couleur.

  4. Répète les étapes 2 et 3 pour chaque couleur primaire.

La valeur alpha n’est jamais entièrement opaque et les rectangles se chevauchent de sorte que vous obtenez des effets de combinaison de couleurs.

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

S’applique à

FromArgb(Int32, Color)

Source:
Color.cs
Source:
Color.cs
Source:
Color.cs

Crée une structure Color à partir de la structure Color spécifiée, mais avec la nouvelle valeur alpha spécifiée. Bien que cette méthode permette de passer une valeur 32 bits pour la valeur alpha, cette dernière est limitée à 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

Paramètres

alpha
Int32

Valeur alpha du nouveau Color. Les valeurs autorisées sont comprises entre 0 et 255.

baseColor
Color

Color à partir duquel créer le Color.

Retours

Color créé par cette méthode.

Exceptions

alpha est inférieur à 0 ou supérieur à 255.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

  1. Crée des Color structures à partir des trois valeurs de composant de couleur (rouge, vert, bleu). Trois Color structures sont créées, une pour chaque couleur primaire.

  2. Itère au sein d’une plage de valeurs alpha, en modifiant la valeur alpha d’une couleur.

  3. Au cours de chaque itération, définit la couleur d’un pinceau sur la couleur modifiée et peint un rectangle pour afficher la couleur.

  4. Répète les étapes 2 et 3 pour chaque couleur primaire.

La valeur alpha n’est jamais entièrement opaque et les rectangles se chevauchent de sorte que vous obtenez des effets de combinaison de couleurs.

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

Remarques

Pour créer une couleur opaque, définissez sur alpha 255. Pour créer une couleur semi-transparence, définissez alpha sur n’importe quelle valeur comprise entre 1 et 254.

S’applique à

FromArgb(Int32)

Source:
Color.cs
Source:
Color.cs
Source:
Color.cs

Crée une structure Color à partir d'une valeur ARVB 32 bits.

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

Paramètres

argb
Int32

Valeur spécifiant la valeur ARVB 32 bits.

Retours

Structure Color créée par cette méthode.

Exemples

L’exemple de code suivant est conçu pour être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du Paint gestionnaire d’événements. Le code effectue les actions suivantes :

  • Crée trois pinceaux, chacun d’une couleur différente. Chaque Color structure utilisée pour créer un pinceau est créée à partir d’une valeur ARGB 32 bits.

  • Utilise un triangle imaginaire pour positionner trois cercles.

  • Peint trois cercles qui se chevauchent, chacun centré sur un sommet du triangle, à l’aide d’un pinceau différent pour chaque cercle.

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

Remarques

L’ordre des octets de la valeur ARGB 32 bits est AARRGGBB. L’octet le plus significatif (MSB), représenté par AA, est la valeur du composant alpha. Les deuxième, troisième et quatrième octets, représentés par RR, GG et BB, respectivement, sont les composants de couleur rouge, vert et bleu, respectivement.

S’applique à