Assembly : System.Drawing (dans system.drawing.dll)
SyntaxePublic Shared Function FromArgb ( _ argb As Integer _ ) As Color
Dim argb As Integer Dim returnValue As Color returnValue = Color.FromArgb(argb)
public static Color FromArgb ( int argb )
public: static Color FromArgb ( int argb )
public static Color FromArgb ( int argb )
public static function FromArgb ( argb : int ) : Color
Paramètres
- argb
Valeur spécifiant la valeur ARVB 32 bits.
Valeur de retour
Structure Color créée par cette méthode.
NotesL'ordre d'octets de la valeur ARVB 32 bits est AARRVVBB. L'octet le plus significatif, représenté par AA, correspond à la valeur du composant alpha. Les second, troisième et quatrième octets, représentés par RR, VV et BB, correspondent aux composants de couleur rouge, vert et bleu, respectivement.
ExempleL'exemple de code suivant est destiné à être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d'événements Paint. Le code exécute les actions suivantes :
-
Crée trois pinceaux de couleur différente. Chaque structure Color servant à la création d'un pinceau est créée à partir d'une valeur ARVB 32 bits.
-
Positionne trois cercles à l'aide d'un triangle imaginaire.
-
Peint trois cercles qui se chevauchent à l'aide de trois pinceaux différents, en centrant chaque cercle sur un vertex différent du triangle.
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
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); }
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.get_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); } //FromArgb4
Plates-formesWindows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile pour Pocket PC, Windows Mobile pour Smartphone, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Informations de version
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ