Icon.ToBitmap Método
Definición
Importante
Parte de la información hace referencia a la versión preliminar del producto, que puede haberse modificado sustancialmente antes de lanzar la versión definitiva. Microsoft no otorga ninguna garantía, explícita o implícita, con respecto a la información proporcionada aquí.
public:
System::Drawing::Bitmap ^ ToBitmap();
public System.Drawing.Bitmap ToBitmap();
member this.ToBitmap : unit -> System.Drawing.Bitmap
Public Function ToBitmap () As Bitmap
Devoluciones
Bitmap que representa el objeto convertidoIcon.
Ejemplos
En el ejemplo de código siguiente se muestra cómo usar el ToBitmap método . Este ejemplo está diseñado para usarse con Windows Forms. Cree un formulario y pegue el código siguiente en él. Llame al IconToBitmap método en el controlador de eventos .Paint del formulario, pasando e como 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
Comentarios
Las áreas transparentes del icono se pierden cuando se convierten en un mapa de bits y el color transparente del mapa de bits resultante se establece en RGB(13,11,12). El mapa de bits devuelto tiene el mismo alto y ancho que el icono original.