Icon.ToBitmap Methode
Definition
Wichtig
Einige Informationen beziehen sich auf Vorabversionen, die vor dem Release ggf. grundlegend überarbeitet werden. Microsoft übernimmt hinsichtlich der hier bereitgestellten Informationen keine Gewährleistungen, seien sie ausdrücklich oder konkludent.
public:
System::Drawing::Bitmap ^ ToBitmap();
public System.Drawing.Bitmap ToBitmap();
member this.ToBitmap : unit -> System.Drawing.Bitmap
Public Function ToBitmap () As Bitmap
Gibt zurück
A Bitmap , das die konvertierte Icon.
Beispiele
Im folgenden Codebeispiel wird die Verwendung der ToBitmap Methode veranschaulicht. Dieses Beispiel wurde für die Verwendung mit Windows Forms entwickelt. Erstellen Sie ein Formular, und fügen Sie den folgenden Code in das Formular ein. Rufen Sie die IconToBitmap Methode im EreignishandlerPaint des Formulars auf, und übergeben Sie sie e als 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
Hinweise
Die transparenten Bereiche des Symbols gehen verloren, wenn es in eine Bitmap konvertiert wird, und die transparente Farbe der resultierenden Bitmap wird auf .RGB(13,11,12) Die zurückgegebene Bitmap weist die gleiche Höhe und Breite wie das ursprüngliche Symbol auf.