Icon.ToBitmap Méthode

Définition

Convertit ce paramètre Icon en GDI+ Bitmap.

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.

S’applique à