Export (0) Print
Expand All

Image Class

Updated: September 2008

An abstract base class that provides functionality for the Bitmap and Metafile descended classes.

Namespace:  System.Drawing
Assembly:  System.Drawing (in System.Drawing.dll)

[SerializableAttribute]
[ComVisibleAttribute(true)]
[TypeConverterAttribute(typeof(ImageConverter))]
public abstract class Image : MarshalByRefObject, 
	ISerializable, ICloneable, IDisposable

To draw an Image on a Windows Form, you should use one of the DrawImage(Image, Point) methods.

The following code example is designed for use with Windows Forms. It is a handler for the Paint event. A Graphics object is passed to the event and is used to draw the image on the form. The code performs the following actions:

  • Creates an image from a file named SampImag.jpg. This file must be located in the same folder as the application executable file.

  • Creates a point at which to draw the upper-left corner of the image.

  • Draws the unscaled image on the form.

private void ImageExampleForm_Paint(object sender, PaintEventArgs e)
{         
    // Create image.
    Image newImage = Image.FromFile("SampImag.jpg");

    // Create Point for upper-left corner of image.
    Point ulCorner = new Point(100, 100);

    // Draw image to screen.
    e.Graphics.DrawImage(newImage, ulCorner);
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Date

History

Reason

September 2008

Updated code example.

Customer feedback.

Community Additions

ADD
Show:
© 2014 Microsoft