Image Image Image Image Class

Definition

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

public ref class Image abstract : MarshalByRefObject, ICloneable, IDisposable, System::Runtime::Serialization::ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))]
[System.Runtime.InteropServices.ComVisible(true)]
[Serializable]
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
type Image = class
    inherit MarshalByRefObject
    interface ISerializable
    interface ICloneable
    interface IDisposable
Public MustInherit Class Image
Inherits MarshalByRefObject
Implements ICloneable, IDisposable, ISerializable
Inheritance
Derived
Attributes
Implements

Examples

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(System::Object^  sender, System::Windows::Forms::PaintEventArgs^  e) 
   {
      // Create image.
      Image^ newImage = Image::FromFile( "SampImag.jpg" );

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

      // Draw image to screen.
      e->Graphics->DrawImage( newImage, ulCorner );
   }
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);
}
Private Sub ImageExampleForm_Paint _
    (ByVal sender As System.Object, _
    ByVal e As System.Windows.Forms.PaintEventArgs) _
    Handles MyBase.Paint


    ' Create image.
    Dim newImage As Image = Image.FromFile("SampImag.jpg")

    ' Create Point for upper-left corner of image.
    Dim ulCorner As New Point(100, 100)

    ' Draw image to screen.
    e.Graphics.DrawImage(newImage, ulCorner)
End Sub

Remarks

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

Properties

Flags Flags Flags Flags

Gets attribute flags for the pixel data of this Image.

FrameDimensionsList FrameDimensionsList FrameDimensionsList FrameDimensionsList

Gets an array of GUIDs that represent the dimensions of frames within this Image.

Height Height Height Height

Gets the height, in pixels, of this Image.

HorizontalResolution HorizontalResolution HorizontalResolution HorizontalResolution

Gets the horizontal resolution, in pixels per inch, of this Image.

Palette Palette Palette Palette

Gets or sets the color palette used for this Image.

PhysicalDimension PhysicalDimension PhysicalDimension PhysicalDimension

Gets the width and height of this image.

PixelFormat PixelFormat PixelFormat PixelFormat

Gets the pixel format for this Image.

PropertyIdList PropertyIdList PropertyIdList PropertyIdList

Gets IDs of the property items stored in this Image.

PropertyItems PropertyItems PropertyItems PropertyItems

Gets all the property items (pieces of metadata) stored in this Image.

RawFormat RawFormat RawFormat RawFormat

Gets the file format of this Image.

Size Size Size Size

Gets the width and height, in pixels, of this image.

Tag Tag Tag Tag

Gets or sets an object that provides additional data about the image.

VerticalResolution VerticalResolution VerticalResolution VerticalResolution

Gets the vertical resolution, in pixels per inch, of this Image.

Width Width Width Width

Gets the width, in pixels, of this Image.

Methods

Clone() Clone() Clone() Clone()

Creates an exact copy of this Image.

CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type) CreateObjRef(Type)

Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.

(Inherited from MarshalByRefObject)
Dispose() Dispose() Dispose() Dispose()

Releases all resources used by this Image.

Dispose(Boolean) Dispose(Boolean) Dispose(Boolean) Dispose(Boolean)

Releases the unmanaged resources used by the Image and optionally releases the managed resources.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Finalize() Finalize() Finalize() Finalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.

FromFile(String) FromFile(String) FromFile(String) FromFile(String)

Creates an Image from the specified file.

FromFile(String, Boolean) FromFile(String, Boolean) FromFile(String, Boolean) FromFile(String, Boolean)

Creates an Image from the specified file using embedded color management information in that file.

FromHbitmap(IntPtr) FromHbitmap(IntPtr) FromHbitmap(IntPtr) FromHbitmap(IntPtr)

Creates a Bitmap from a handle to a GDI bitmap.

FromHbitmap(IntPtr, IntPtr) FromHbitmap(IntPtr, IntPtr) FromHbitmap(IntPtr, IntPtr) FromHbitmap(IntPtr, IntPtr)

Creates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.

FromStream(Stream) FromStream(Stream) FromStream(Stream) FromStream(Stream)

Creates an Image from the specified data stream.

FromStream(Stream, Boolean) FromStream(Stream, Boolean) FromStream(Stream, Boolean) FromStream(Stream, Boolean)

Creates an Image from the specified data stream, optionally using embedded color management information in that stream.

FromStream(Stream, Boolean, Boolean) FromStream(Stream, Boolean, Boolean) FromStream(Stream, Boolean, Boolean) FromStream(Stream, Boolean, Boolean)

Creates an Image from the specified data stream, optionally using embedded color management information and validating the image data.

GetBounds(GraphicsUnit) GetBounds(GraphicsUnit) GetBounds(GraphicsUnit) GetBounds(GraphicsUnit)

Gets the bounds of the image in the specified unit.

GetEncoderParameterList(Guid) GetEncoderParameterList(Guid) GetEncoderParameterList(Guid) GetEncoderParameterList(Guid)

Returns information about the parameters supported by the specified image encoder.

GetFrameCount(FrameDimension) GetFrameCount(FrameDimension) GetFrameCount(FrameDimension) GetFrameCount(FrameDimension)

Returns the number of frames of the specified dimension.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetLifetimeService() GetLifetimeService() GetLifetimeService() GetLifetimeService()

Retrieves the current lifetime service object that controls the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
GetPixelFormatSize(PixelFormat) GetPixelFormatSize(PixelFormat) GetPixelFormatSize(PixelFormat) GetPixelFormatSize(PixelFormat)

Returns the color depth, in number of bits per pixel, of the specified pixel format.

GetPropertyItem(Int32) GetPropertyItem(Int32) GetPropertyItem(Int32) GetPropertyItem(Int32)

Gets the specified property item from this Image.

GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr) GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr) GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr) GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr)

Returns a thumbnail for this Image.

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService() InitializeLifetimeService()

Obtains a lifetime service object to control the lifetime policy for this instance.

(Inherited from MarshalByRefObject)
IsAlphaPixelFormat(PixelFormat) IsAlphaPixelFormat(PixelFormat) IsAlphaPixelFormat(PixelFormat) IsAlphaPixelFormat(PixelFormat)

Returns a value that indicates whether the pixel format for this Image contains alpha information.

IsCanonicalPixelFormat(PixelFormat) IsCanonicalPixelFormat(PixelFormat) IsCanonicalPixelFormat(PixelFormat) IsCanonicalPixelFormat(PixelFormat)

Returns a value that indicates whether the pixel format is 32 bits per pixel.

IsExtendedPixelFormat(PixelFormat) IsExtendedPixelFormat(PixelFormat) IsExtendedPixelFormat(PixelFormat) IsExtendedPixelFormat(PixelFormat)

Returns a value that indicates whether the pixel format is 64 bits per pixel.

MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean) MemberwiseClone(Boolean)

Creates a shallow copy of the current MarshalByRefObject object.

(Inherited from MarshalByRefObject)
RemovePropertyItem(Int32) RemovePropertyItem(Int32) RemovePropertyItem(Int32) RemovePropertyItem(Int32)

Removes the specified property item from this Image.

RotateFlip(RotateFlipType) RotateFlip(RotateFlipType) RotateFlip(RotateFlipType) RotateFlip(RotateFlipType)

Rotates, flips, or rotates and flips the Image.

Save(Stream, ImageCodecInfo, EncoderParameters) Save(Stream, ImageCodecInfo, EncoderParameters) Save(Stream, ImageCodecInfo, EncoderParameters) Save(Stream, ImageCodecInfo, EncoderParameters)

Saves this image to the specified stream, with the specified encoder and image encoder parameters.

Save(Stream, ImageFormat) Save(Stream, ImageFormat) Save(Stream, ImageFormat) Save(Stream, ImageFormat)

Saves this image to the specified stream in the specified format.

Save(String) Save(String) Save(String) Save(String)

Saves this Image to the specified file or stream.

Save(String, ImageCodecInfo, EncoderParameters) Save(String, ImageCodecInfo, EncoderParameters) Save(String, ImageCodecInfo, EncoderParameters) Save(String, ImageCodecInfo, EncoderParameters)

Saves this Image to the specified file, with the specified encoder and image-encoder parameters.

Save(String, ImageFormat) Save(String, ImageFormat) Save(String, ImageFormat) Save(String, ImageFormat)

Saves this Image to the specified file in the specified format.

SaveAdd(EncoderParameters) SaveAdd(EncoderParameters) SaveAdd(EncoderParameters) 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.

SaveAdd(Image, EncoderParameters) SaveAdd(Image, EncoderParameters) SaveAdd(Image, EncoderParameters) SaveAdd(Image, EncoderParameters)

Adds a frame to the file or stream specified in a previous call to the Save method.

SelectActiveFrame(FrameDimension, Int32) SelectActiveFrame(FrameDimension, Int32) SelectActiveFrame(FrameDimension, Int32) SelectActiveFrame(FrameDimension, Int32)

Selects the frame specified by the dimension and index.

SetPropertyItem(PropertyItem) SetPropertyItem(PropertyItem) SetPropertyItem(PropertyItem) SetPropertyItem(PropertyItem)

Stores a property item (piece of metadata) in this Image.

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Explicit Interface Implementations

ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext) ISerializable.GetObjectData(SerializationInfo, StreamingContext)

Populates a SerializationInfo with the data needed to serialize the target object.

Applies to

See Also