9 out of 14 rated this helpful - Rate this topic

Image Class

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

The Image type exposes the following members.

  Name Description
Public property Flags Gets attribute flags for the pixel data of this Image.
Public property FrameDimensionsList Gets an array of GUIDs that represent the dimensions of frames within this Image.
Public property Height Gets the height, in pixels, of this Image.
Public property HorizontalResolution Gets the horizontal resolution, in pixels per inch, of this Image.
Public property Palette Gets or sets the color palette used for this Image.
Public property PhysicalDimension Gets the width and height of this image.
Public property PixelFormat Gets the pixel format for this Image.
Public property PropertyIdList Gets IDs of the property items stored in this Image.
Public property PropertyItems Gets all the property items (pieces of metadata) stored in this Image.
Public property RawFormat Gets the file format of this Image.
Public property Size Gets the width and height, in pixels, of this image.
Public property Tag Gets or sets an object that provides additional data about the image.
Public property VerticalResolution Gets the vertical resolution, in pixels per inch, of this Image.
Public property Width Gets the width, in pixels, of this Image.
Top
  Name Description
Public method Clone Creates an exact copy of this Image.
Public method CreateObjRef Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public method Dispose() Releases all resources used by this Image.
Protected method Dispose(Boolean) Releases the unmanaged resources used by the Image and optionally releases the managed resources.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public method Static member FromFile(String) Creates an Image from the specified file.
Public method Static member FromFile(String, Boolean) Creates an Image from the specified file using embedded color management information in that file.
Public method Static member FromHbitmap(IntPtr) Creates a Bitmap from a handle to a GDI bitmap.
Public method Static member FromHbitmap(IntPtr, IntPtr) Creates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.
Public method Static member FromStream(Stream) Creates an Image from the specified data stream.
Public method Static member FromStream(Stream, Boolean) Creates an Image from the specified data stream, optionally using embedded color management information in that stream.
Public method Static member FromStream(Stream, Boolean, Boolean) Creates an Image from the specified data stream, optionally using embedded color management information and validating the image data.
Public method GetBounds Gets the bounds of the image in the specified unit.
Public method GetEncoderParameterList Returns information about the parameters supported by the specified image encoder.
Public method GetFrameCount Returns the number of frames of the specified dimension.
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetLifetimeService Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method Static member GetPixelFormatSize Returns the color depth, in number of bits per pixel, of the specified pixel format.
Public method GetPropertyItem Gets the specified property item from this Image.
Public method GetThumbnailImage Returns a thumbnail for this Image.
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method InitializeLifetimeService Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public method Static member IsAlphaPixelFormat Returns a value that indicates whether the pixel format for this Image contains alpha information.
Public method Static member IsCanonicalPixelFormat Returns a value that indicates whether the pixel format is 32 bits per pixel.
Public method Static member IsExtendedPixelFormat Returns a value that indicates whether the pixel format is 64 bits per pixel.
Protected method MemberwiseClone() Creates a shallow copy of the current Object. (Inherited from Object.)
Protected method MemberwiseClone(Boolean) Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public method RemovePropertyItem Removes the specified property item from this Image.
Public method RotateFlip Rotates, flips, or rotates and flips the Image.
Public method Save(String) Saves this Image to the specified file or stream.
Public method Save(Stream, ImageFormat) Saves this image to the specified stream in the specified format.
Public method Save(String, ImageFormat) Saves this Image to the specified file in the specified format.
Public method Save(Stream, ImageCodecInfo, EncoderParameters) Saves this image to the specified stream, with the specified encoder and image encoder parameters.
Public method Save(String, ImageCodecInfo, EncoderParameters) Saves this Image to the specified file, with the specified encoder and image-encoder parameters.
Public method SaveAdd(EncoderParameters) Adds a frame to the file or stream specified in a previous call to the Save method. Use this method to save selected frames from a multiple-frame image to another multiple-frame image.
Public method SaveAdd(Image, EncoderParameters) Adds a frame to the file or stream specified in a previous call to the Save method.
Public method SelectActiveFrame Selects the frame specified by the dimension and index.
Public method SetPropertyItem Stores a property item (piece of metadata) in this Image.
Public method ToString Returns a string that represents the current object. (Inherited from Object.)
Top
  Name Description
Explicit interface implemetation Private method ISerializable.GetObjectData Populates a SerializationInfo with the data needed to serialize the target object.
Top

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);
}


.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Piczard .NET Image Manipulation Library
Piczard (http://piczard.com/) is a Free Image Manipulation Library - ASP.NET medium trust compatible - that uses the standard Windows GDI+ library (System.Drawing) to read / write / manipulate images. $0The library includes an advanced WYSIWYG Image Resizer / Cropper Tool for ASP.NET$0
ImageResizing.Net
The http://imageresizing.net open-source project wraps System.Drawing, making it safe for use in ASP.NET applications.