Assembly : System.Drawing (dans system.drawing.dll)
SyntaxePublic Sub DrawImage ( _ image As Image, _ x As Single, _ y As Single, _ width As Single, _ height As Single _ )
Dim instance As Graphics Dim image As Image Dim x As Single Dim y As Single Dim width As Single Dim height As Single instance.DrawImage(image, x, y, width, height)
public void DrawImage ( Image image, float x, float y, float width, float height )
public: void DrawImage ( Image^ image, float x, float y, float width, float height )
public void DrawImage ( Image image, float x, float y, float width, float height )
public function DrawImage ( image : Image, x : float, y : float, width : float, height : float )
Paramètres
- image
Image à dessiner.
- x
Coordonnée x de l'angle supérieur gauche de l'image dessinée.
- y
Coordonnée y de l'angle supérieur gauche de l'image dessinée.
- width
Largeur de l'image dessinée.
- height
Hauteur de l'image dessinée.
NotesLe rectangle défini par les paramètres x, y, width et height détermine la position et la taille de l'image dessinée.
ExempleL'exemple de code suivant est destiné à être utilisé avec Windows Forms et nécessite PaintEventArgse, qui est un paramètre du gestionnaire d'événements Paint. Le code exécute les actions suivantes :
-
Crée une image à partir d'un fichier JPEG, SampImag.jpg, dans le dossier de l'exemple.
-
Crée la position et la taille d'un rectangle dans lequel dessiner l'image.
-
Dessine l'image à l'écran.
La position du rectangle situe l'image à l'écran, tandis que la taille de l'image d'origine et la taille du rectangle déterminent la mise à l'échelle de l'image dessinée.
Public Sub DrawImage4Float(ByVal e As PaintEventArgs) ' Create image. Dim newImage As Image = Image.FromFile("SampImag.jpg") ' Create coordinates for upper-left corner ' of image and for size of image. Dim x As Single = 100.0F Dim y As Single = 100.0F Dim width As Single = 450.0F Dim height As Single = 150.0F ' Draw image to screen. e.Graphics.DrawImage(newImage, x, y, width, height) End Sub
public void DrawImage4Float(PaintEventArgs e) { // Create image. Image newImage = Image.FromFile("SampImag.jpg"); // Create coordinates for upper-left corner. // of image and for size of image. float x = 100.0F; float y = 100.0F; float width = 450.0F; float height = 150.0F; // Draw image to screen. e.Graphics.DrawImage(newImage, x, y, width, height); }
public: void DrawImage4Float( PaintEventArgs^ e ) { // Create image. Image^ newImage = Image::FromFile( "SampImag.jpg" ); // Create coordinates for upper-left corner. // of image and for size of image. float x = 100.0F; float y = 100.0F; float width = 450.0F; float height = 150.0F; // Draw image to screen. e->Graphics->DrawImage( newImage, x, y, width, height ); }
public void DrawImage4Float(PaintEventArgs e) { // Create image. Image newImage = Image.FromFile("SampImag.jpg"); // Create coordinates for upper-left corner. // of image and for size of image. float x = 100; float y = 100; float width = 450; float height = 150; // Draw image to screen. e.get_Graphics().DrawImage(newImage, x, y, width, height); } //DrawImage4Float
Plates-formesWindows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Édition Media Center, Windows XP Professionnel Édition x64, Windows XP SP2, Windows XP Starter Edition
Le .NET Framework ne prend pas en charge toutes les versions de chaque plate-forme. Pour obtenir la liste des versions prises en charge, consultez Configuration requise.
Voir aussiRéférence
Graphics, classeMembres Graphics
System.Drawing, espace de noms
Outils (masquer)
S'enregistrer
Liste des Membres
Qui est en ligne?
FAQ