This documentation is archived and is not being maintained.

Graphics.DrawImage Method (Image, PointF[])

.NET Framework 1.1

Draws the specified Image object at the specified location and with the specified shape and size.

[Visual Basic]
Overloads Public Sub DrawImage( _
   ByVal image As Image, _
   ByVal destPoints() As PointF _
)
[C#]
public void DrawImage(
 Image image,
 PointF[] destPoints
);
[C++]
public: void DrawImage(
 Image* image,
 PointF destPoints[]
);
[JScript]
public function DrawImage(
   image : Image,
 destPoints : PointF[]
);

Parameters

image
Image object to draw.
destPoints
Array of three PointF structures that define a parallelogram.

Return Value

This method does not return a value.

Remarks

The destPoints parameter specifies three points of a parallelogram. The three PointF structures represent the upper-left, upper-right, and lower-left corners of the parallelogram. The fourth point is extrapolated from the first three to form a parallelogram.

The image represented by the image object is scaled and sheared to fit the shape of the parallelogram specified by the destPoints parameter.

Example

[Visual Basic, C#] The following example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler. The code performs the following actions:

  • Creates an image from a JPEG file SampImag.jpg in the folder of the example.
  • Creates points that define a parallelogram in which to draw the image.
  • Draws the image to the screen.

[Visual Basic, C#] The position of the parallelogram locates the image on the screen, and the size of the original image and the size and shape of the parallelogram determines the scaling and shearing of the drawn image.

[Visual Basic] 
Public Sub DrawImageParaF(e As PaintEventArgs)
' Create image.
Dim newImage As Image = Image.FromFile("SampImag.jpg")
' Create parallelogram for drawing image.
Dim ulCorner As New PointF(100F, 100F)
Dim urCorner As New PointF(550F, 100F)
Dim llCorner As New PointF(150F, 250F)
Dim destPara As PointF() =  {ulCorner, urCorner, llCorner}
' Draw image to screen.
e.Graphics.DrawImage(newImage, destPara)
End Sub
        
[C#] 
public void DrawImageParaF(PaintEventArgs e)
{
// Create image.
Image newImage = Image.FromFile("SampImag.jpg");
// Create parallelogram for drawing image.
PointF ulCorner = new PointF(100.0F, 100.0F);
PointF urCorner = new PointF(550.0F, 100.0F);
PointF llCorner = new PointF(150.0F, 250.0F);
PointF[] destPara = {ulCorner, urCorner, llCorner};
// Draw image to screen.
e.Graphics.DrawImage(newImage, destPara);
}
        

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Graphics Class | Graphics Members | System.Drawing Namespace | Graphics.DrawImage Overload List

Show: