Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
Puede usar GDI+ para representar imágenes que existen como archivos en las aplicaciones. Para ello, cree un nuevo objeto de una Image clase (como Bitmap), creando un Graphics objeto que haga referencia a la superficie de dibujo que desea usar y llamando al DrawImage método del Graphics objeto . La imagen se pintará en la superficie de dibujo indicada por la clase gráfica. Puede usar el Editor de imágenes para crear y editar archivos de imagen en tiempo de diseño y representarlos con GDI+ en tiempo de ejecución. Para obtener más información, vea Editor de imágenes para iconos.
Para representar una imagen con GDI+
Cree un objeto que represente la imagen que desea mostrar. Este objeto debe ser miembro de una clase que hereda de Image, como Bitmap o Metafile. Se muestra un ejemplo:
' Uses the System.Environment.GetFolderPath to get the path to the ' current user's MyPictures folder. Dim myBitmap as New Bitmap _ (System.Environment.GetFolderPath _ (System.Environment.SpecialFolder.MyPictures))
// Uses the System.Environment.GetFolderPath to get the path to the // current user's MyPictures folder. Bitmap myBitmap = new Bitmap (System.Environment.GetFolderPath (System.Environment.SpecialFolder.MyPictures));
// Uses the System.Environment.GetFolderPath to get the path to the // current user's MyPictures folder. Bitmap^ myBitmap = gcnew Bitmap (System::Environment::GetFolderPath (System::Environment::SpecialFolder::MyPictures));
Cree un Graphics objeto que represente la superficie de dibujo que desea usar. Para obtener más información, vea Cómo: Crear objetos gráficos para dibujar.
' Creates a Graphics object that represents the drawing surface of ' Button1. Dim g as Graphics = Button1.CreateGraphics
// Creates a Graphics object that represents the drawing surface of // Button1. Graphics g = Button1.CreateGraphics();
// Creates a Graphics object that represents the drawing surface of // Button1. Graphics^ g = button1->CreateGraphics();
Llame a la función DrawImage de su objeto de gráficos para representar la imagen. Debe especificar la imagen que se va a dibujar y las coordenadas donde se va a dibujar.
g.DrawImage(myBitmap, 1, 1)
g.DrawImage(myBitmap, 1, 1);
g->DrawImage(myBitmap, 1, 1);
Consulte también
.NET Desktop feedback