Icon.ToBitmap Méthode
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
public:
System::Drawing::Bitmap ^ ToBitmap();
public System.Drawing.Bitmap ToBitmap();
member this.ToBitmap : unit -> System.Drawing.Bitmap
Public Function ToBitmap () As Bitmap
Retours
Qui Bitmap représente le fichier converti Icon.
Exemples
L’exemple de code suivant montre comment utiliser la ToBitmap méthode. Cet exemple est conçu pour être utilisé avec Windows Forms. Créez un formulaire et collez-y le code suivant. Appelez la IconToBitmap méthode dans le gestionnaire d’événements .Paint du formulaire, en passant e en tant que PaintEventArgs .
private:
void IconToBitmap( PaintEventArgs^ e )
{
// Construct an Icon.
System::Drawing::Icon^ icon1 = gcnew System::Drawing::Icon( SystemIcons::Exclamation,40,40 );
// Call ToBitmap to convert it.
Bitmap^ bmp = icon1->ToBitmap();
// Draw the bitmap.
e->Graphics->DrawImage( bmp, Point(30,30) );
}
private void IconToBitmap(PaintEventArgs e)
{
// Construct an Icon.
Icon icon1 = new Icon(SystemIcons.Exclamation, 40, 40);
// Call ToBitmap to convert it.
Bitmap bmp = icon1.ToBitmap();
// Draw the bitmap.
e.Graphics.DrawImage(bmp, new Point(30, 30));
}
Private Sub IconToBitmap(ByVal e As PaintEventArgs)
' Construct an Icon.
Dim icon1 As New Icon(SystemIcons.Exclamation, 40, 40)
' Call ToBitmap to convert it.
Dim bmp As Bitmap = icon1.ToBitmap()
' Draw the bitmap.
e.Graphics.DrawImage(bmp, New Point(30, 30))
End Sub
Remarques
Les zones transparentes de l’icône sont perdues lorsqu’elles sont converties en bitmap, et la couleur transparente de la bitmap résultante est définie RGB(13,11,12)sur . La bitmap retournée a la même hauteur et la même largeur que l’icône d’origine.