Icon.ToBitmap Method
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
public:
System::Drawing::Bitmap ^ ToBitmap();
public System.Drawing.Bitmap ToBitmap();
member this.ToBitmap : unit -> System.Drawing.Bitmap
Public Function ToBitmap () As Bitmap
A Bitmap that represents the converted Icon.
The following code example demonstrates how to use the ToBitmap method. This example is designed to be used with Windows Forms. Create a form and paste the following code into it. Call the IconToBitmap
method in the form's .Paint event handler, passing e
as 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
The transparent areas of the icon are lost when it is converted to a bitmap, and the transparent color of the resulting bitmap is set to RGB(13,11,12)
. The returned bitmap has the same height and width as the original icon.
Produkt | Verzie |
---|---|
.NET | 8 (package-provided), 9 (package-provided), 10 (package-provided) |
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0 (package-provided) |
Windows Desktop | 3.0, 3.1, 5, 6, 7, 8, 9, 10 |
Pripomienky k produktu .NET
.NET je open-source projekt. Ak chcete poskytnúť pripomienky, vyberte prepojenie: