Color.FromArgb Metodo

Definizione

Crea una struttura Color dai valori dei quattro componenti ARGB a 8 bit (alfa, rosso, verde e blu).

Overload

FromArgb(Int32, Int32, Int32, Int32)

Crea una struttura Color dai valori dei quattro componenti ARGB: alfa, rosso, verde e blu. Sebbene questo metodo consenta di passare un valore a 32 bit per ciascun componente, il valore di ognuno dei componenti è limitato a 8 bit.

FromArgb(Int32, Int32, Int32)

Crea una struttura Color dai valori a 8 bit dei colori specificati: rosso, verde e blu. Il valore alfa è implicitamente 255 (completamente opaco). Sebbene questo metodo consenta di passare un valore a 32 bit per ciascun componente di colore, il valore di ognuno dei componenti è limitato a 8 bit.

FromArgb(Int32, Color)

Crea una struttura Color dalla struttura Color specificata, ma con il nuovo valore alfa specificato. Sebbene questo metodo consenta di passare un valore a 32 bit per il valore alfa, il valore è limitato a 8 bit.

FromArgb(Int32)

Crea una struttura Color da un valore ARGB a 32 bit.

FromArgb(Int32, Int32, Int32, Int32)

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

Crea una struttura Color dai valori dei quattro componenti ARGB: alfa, rosso, verde e blu. Sebbene questo metodo consenta di passare un valore a 32 bit per ciascun componente, il valore di ognuno dei componenti è limitato a 8 bit.

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

Parametri

alpha
Int32

Componente alfa. I valori validi sono compresi tra 0 e 255.

red
Int32

Componente rosso. I valori validi sono compresi tra 0 e 255.

green
Int32

Componente verde. I valori validi sono compresi tra 0 e 255.

blue
Int32

Componente blu. I valori validi sono compresi tra 0 e 255.

Restituisce

Oggetto Color creato con questo metodo.

Eccezioni

alpha,red, green o blue è minore di 0 o maggiore di 255.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:

  • Crea tre pennelli, ognuno con un colore diverso. Ogni Color struttura usata per creare un pennello viene creata da quattro valori dei componenti (alfa, rosso, verde, blu).

  • Usa un triangolo immaginario per posizionare tre cerchi.

  • Disegna tre cerchi sovrapposti, ognuno centrato su un vertice del triangolo, utilizzando un pennello diverso per ogni cerchio.

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

Commenti

Per creare un colore opaco, impostare su alpha 255. Per creare un colore semitrasparente, impostare su alpha qualsiasi valore compreso tra 1 e 254.

Si applica a

FromArgb(Int32, Int32, Int32)

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

Crea una struttura Color dai valori a 8 bit dei colori specificati: rosso, verde e blu. Il valore alfa è implicitamente 255 (completamente opaco). Sebbene questo metodo consenta di passare un valore a 32 bit per ciascun componente di colore, il valore di ognuno dei componenti è limitato a 8 bit.

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

Parametri

red
Int32

Valore del componente rosso per la nuova struttura Color. I valori validi sono compresi tra 0 e 255.

green
Int32

Valore del componente verde per la nuova struttura Color. I valori validi sono compresi tra 0 e 255.

blue
Int32

Valore del componente blu per la nuova struttura Color. I valori validi sono compresi tra 0 e 255.

Restituisce

Oggetto Color creato con questo metodo.

Eccezioni

red,green oblue è minore di 0 o maggiore di 255.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:

  1. Crea Color strutture dai tre valori dei componenti colore (rosso, verde, blu). Vengono create tre Color strutture, una per ogni colore primario.

  2. Scorre un intervallo di valori alfa, modificando il valore alfa di un colore.

  3. Durante ogni iterazione, imposta il colore di un pennello sul colore modificato e disegna un rettangolo per mostrare il colore.

  4. Ripete i passaggi 2 e 3 per ogni colore primario.

Il valore alfa non è mai completamente opaco e i rettangoli si sovrappongono in modo da ottenere effetti di combinazione di colori.

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

Si applica a

FromArgb(Int32, Color)

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

Crea una struttura Color dalla struttura Color specificata, ma con il nuovo valore alfa specificato. Sebbene questo metodo consenta di passare un valore a 32 bit per il valore alfa, il valore è limitato a 8 bit.

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

Parametri

alpha
Int32

Valore alfa per la nuova struttura Color. I valori validi sono compresi tra 0 e 255.

baseColor
Color

Oggetto Color da cui creare il nuovo oggetto Color.

Restituisce

Oggetto Color creato con questo metodo.

Eccezioni

alpha è minore di 0 o maggiore di 255.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:

  1. Crea Color strutture dai tre valori dei componenti colore (rosso, verde, blu). Vengono create tre Color strutture, una per ogni colore primario.

  2. Scorre un intervallo di valori alfa, modificando il valore alfa di un colore.

  3. Durante ogni iterazione, imposta il colore di un pennello sul colore modificato e disegna un rettangolo per mostrare il colore.

  4. Ripete i passaggi 2 e 3 per ogni colore primario.

Il valore alfa non è mai completamente opaco e i rettangoli si sovrappongono in modo da ottenere effetti di combinazione di colori.

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

Commenti

Per creare un colore opaco, impostare su alpha 255. Per creare un colore semitrasparente, impostare su alpha qualsiasi valore compreso tra 1 e 254.

Si applica a

FromArgb(Int32)

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

Crea una struttura Color da un valore ARGB a 32 bit.

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

Parametri

argb
Int32

Valore che specifica il valore ARGB a 32 bit.

Restituisce

Struttura Color creata da questo metodo.

Esempio

L'esempio di codice seguente è progettato per l'uso con Windows Forms e richiede PaintEventArgse, che è un parametro del Paint gestore eventi. Il codice esegue le azioni seguenti:

  • Crea tre pennelli, ognuno con un colore diverso. Ogni Color struttura usata per creare un pennello viene creata da un valore ARGB a 32 bit.

  • Usa un triangolo immaginario per posizionare tre cerchi.

  • Disegna tre cerchi sovrapposti, ognuno centrato su un vertice del triangolo, utilizzando un pennello diverso per ogni cerchio.

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

Commenti

L'ordinamento dei byte del valore ARGB a 32 bit è AARRGGBB. Il byte più significativo (MSB), rappresentato da AA, è il valore del componente alfa. Il secondo, il terzo e il quarto byte, rappresentati rispettivamente da RR, GG e BB, sono i componenti di colore rosso, verde e blu rispettivamente.

Si applica a