Export (0) Print
Expand All

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]
[TypeConverterAttribute(typeof(ImageConverter))]
[ComVisibleAttribute(true)]
public abstract class Image : MarshalByRefObject, 
	ISerializable, ICloneable, IDisposable

The Image type exposes the following members.

  NameDescription
Public propertyFlagsGets attribute flags for the pixel data of this Image.
Public propertyFrameDimensionsListGets an array of GUIDs that represent the dimensions of frames within this Image.
Public propertyHeightGets the height, in pixels, of this Image.
Public propertyHorizontalResolutionGets the horizontal resolution, in pixels per inch, of this Image.
Public propertyPaletteGets or sets the color palette used for this Image.
Public propertyPhysicalDimensionGets the width and height of this image.
Public propertyPixelFormatGets the pixel format for this Image.
Public propertyPropertyIdListGets IDs of the property items stored in this Image.
Public propertyPropertyItemsGets all the property items (pieces of metadata) stored in this Image.
Public propertyRawFormatGets the file format of this Image.
Public propertySizeGets the width and height, in pixels, of this image.
Public propertyTagGets or sets an object that provides additional data about the image.
Public propertyVerticalResolutionGets the vertical resolution, in pixels per inch, of this Image.
Public propertyWidthGets the width, in pixels, of this Image.
Top

  NameDescription
Public methodCloneCreates an exact copy of this Image.
Public methodCreateObjRefCreates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.)
Public methodDispose()Releases all resources used by this Image.
Protected methodDispose(Boolean)Releases the unmanaged resources used by the Image and optionally releases the managed resources.
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Overrides Object.Finalize().)
Public methodStatic memberFromFile(String)Creates an Image from the specified file.
Public methodStatic memberFromFile(String, Boolean)Creates an Image from the specified file using embedded color management information in that file.
Public methodStatic memberFromHbitmap(IntPtr)Creates a Bitmap from a handle to a GDI bitmap.
Public methodStatic memberFromHbitmap(IntPtr, IntPtr)Creates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.
Public methodStatic memberFromStream(Stream)Creates an Image from the specified data stream.
Public methodStatic memberFromStream(Stream, Boolean)Creates an Image from the specified data stream, optionally using embedded color management information in that stream.
Public methodStatic memberFromStream(Stream, Boolean, Boolean)Creates an Image from the specified data stream, optionally using embedded color management information and validating the image data.
Public methodGetBoundsGets the bounds of the image in the specified unit.
Public methodGetEncoderParameterListReturns information about the parameters supported by the specified image encoder.
Public methodGetFrameCountReturns the number of frames of the specified dimension.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodGetLifetimeServiceRetrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodStatic memberGetPixelFormatSizeReturns the color depth, in number of bits per pixel, of the specified pixel format.
Public methodGetPropertyItemGets the specified property item from this Image.
Public methodGetThumbnailImageReturns a thumbnail for this Image.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodInitializeLifetimeServiceObtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.)
Public methodStatic memberIsAlphaPixelFormatReturns a value that indicates whether the pixel format for this Image contains alpha information.
Public methodStatic memberIsCanonicalPixelFormatReturns a value that indicates whether the pixel format is 32 bits per pixel.
Public methodStatic memberIsExtendedPixelFormatReturns a value that indicates whether the pixel format is 64 bits per pixel.
Protected methodMemberwiseClone()Creates a shallow copy of the current Object. (Inherited from Object.)
Protected methodMemberwiseClone(Boolean)Creates a shallow copy of the current MarshalByRefObject object. (Inherited from MarshalByRefObject.)
Public methodRemovePropertyItemRemoves the specified property item from this Image.
Public methodRotateFlipRotates, flips, or rotates and flips the Image.
Public methodSave(String)Saves this Image to the specified file or stream.
Public methodSave(Stream, ImageFormat)Saves this image to the specified stream in the specified format.
Public methodSave(String, ImageFormat)Saves this Image to the specified file in the specified format.
Public methodSave(Stream, ImageCodecInfo, EncoderParameters)Saves this image to the specified stream, with the specified encoder and image encoder parameters.
Public methodSave(String, ImageCodecInfo, EncoderParameters)Saves this Image to the specified file, with the specified encoder and image-encoder parameters.
Public methodSaveAdd(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 methodSaveAdd(Image, EncoderParameters)Adds a frame to the file or stream specified in a previous call to the Save method.
Public methodSelectActiveFrameSelects the frame specified by the dimension and index.
Public methodSetPropertyItemStores a property item (piece of metadata) in this Image.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top

  NameDescription
Explicit interface implemetationPrivate methodISerializable.GetObjectDataPopulates 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 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.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

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.
Show:
© 2014 Microsoft