Icon.ToBitmap Metodo

Definizione

Converte l'oggetto Icon in un GDI+ Bitmap.

public:
 System::Drawing::Bitmap ^ ToBitmap();
public System.Drawing.Bitmap ToBitmap();
member this.ToBitmap : unit -> System.Drawing.Bitmap
Public Function ToBitmap () As Bitmap

Valori restituiti

Oggetto Bitmap che rappresenta l'oggetto convertito Icon.

Esempio

Nell'esempio di codice seguente viene illustrato come usare il ToBitmap metodo . Questo esempio è progettato per essere usato con Windows Form. Creare un modulo e incollarvi il codice seguente. Chiamare il IconToBitmap metodo nel gestore eventi . delPaint modulo, passando e come 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

Commenti

Le aree trasparenti dell'icona vengono perse quando viene convertita in una bitmap e il colore trasparente della bitmap risultante viene impostato su RGB(13,11,12). La bitmap restituita ha la stessa altezza e larghezza dell'icona originale.

Si applica a