Image Image Image Image Class

定義

提供功能給 BitmapMetafile 子代類別的抽象基底類別。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)]
[System.Serializable]
[System.ComponentModel.TypeConverter("System.Drawing.ImageConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")]
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
繼承
衍生
屬性
實作

範例

下列程式碼範例被設計為搭配 Windows Form。The following code example is designed for use with Windows Forms. 它是處理常式Paint事件。It is a handler for the Paint event. AGraphics物件會傳遞至事件,並會用來在表單上繪製影像。A Graphics object is passed to the event and is used to draw the image on the form. 該程式碼執行下列動作:The code performs the following actions:

  • 從名為 SampImag.jpg 檔案建立映像。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

備註

若要繪製Image在 Windows 表單中,您應該使用其中一個DrawImage方法。To draw an Image on a Windows Form, you should use one of the DrawImage methods.

屬性

Flags Flags Flags Flags

取得這個 Image 之像素資料的屬性旗標。Gets attribute flags for the pixel data of this Image.

FrameDimensionsList FrameDimensionsList FrameDimensionsList FrameDimensionsList

取得 GUID 的陣列,表示這個 Image 中的框架 (Frame) 維度 (Dimension)。Gets an array of GUIDs that represent the dimensions of frames within this Image.

Height Height Height Height

取得這個 Image 的高度 (單位為像素)。Gets the height, in pixels, of this Image.

HorizontalResolution HorizontalResolution HorizontalResolution HorizontalResolution

取得這個 Image 的水平解析度 (單位為每英吋的像素)。Gets the horizontal resolution, in pixels per inch, of this Image.

Palette Palette Palette Palette

取得或設定用於這個 Image 的調色盤。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

取得這個 Image 的像素格式。Gets the pixel format for this Image.

PropertyIdList PropertyIdList PropertyIdList PropertyIdList

取得儲存在這個 Image 中的屬性項目 ID。Gets IDs of the property items stored in this Image.

PropertyItems PropertyItems PropertyItems PropertyItems

取得儲存在這個 Image 中的所有屬性項目 (中繼資料的各個項目)。Gets all the property items (pieces of metadata) stored in this Image.

RawFormat RawFormat RawFormat RawFormat

取得這個 Image 的檔案格式。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

取得這個 Image 的垂直解析度 (單位為每英吋的像素)。Gets the vertical resolution, in pixels per inch, of this Image.

Width Width Width Width

取得這個 Image 的寬度 (單位為像素)。Gets the width, in pixels, of this Image.

方法

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

建立這個 Image 的完全相同複本。Creates an exact copy of this Image.

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

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。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()

釋放這個 Image 所使用的所有資源。Releases all resources used by this Image.

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

釋放 Image 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。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)

從指定的檔案建立 Image 物件。Creates an Image from the specified file.

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

使用指定之檔案中的內嵌色彩管理資訊,從該檔案建立 ImageCreates an Image from the specified file using embedded color management information in that file.

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

從 GDI 點陣圖控制代碼建立 BitmapCreates a Bitmap from a handle to a GDI bitmap.

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

從 GDI 點陣圖控制代碼和 GDI 調色盤控制代碼建立 BitmapCreates a Bitmap from a handle to a GDI bitmap and a handle to a GDI palette.

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

從指定的資料流建立 ImageCreates an Image from the specified data stream.

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

選擇性地使用指定之資料流中的內嵌色彩管理資訊,從該資料流建立 ImageCreates 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)

選擇性地使用内嵌色彩管理資訊並驗證影像資料,從指定的資料流建立 ImageCreates 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()

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。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)

從這個 Image 取得指定的屬性項目。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)

傳回這個 Image 的縮圖。Returns a thumbnail for this Image.

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

取得目前執行個體的 TypeGets 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)

傳回值,指示這個 Image 的像素格式是否包含 Alpha 資訊。Returns a value that indicates whether the pixel format for this Image contains alpha information.

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

傳回值,指示像素格式是否為每像素 32 位元。Returns a value that indicates whether the pixel format is 32 bits per pixel.

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

傳回值,指示像素格式是否為每像素 64 位元。Returns a value that indicates whether the pixel format is 64 bits per pixel.

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

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

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

建立目前 MarshalByRefObject 物件的淺層複本。Creates a shallow copy of the current MarshalByRefObject object.

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

將指定的屬性項目從這個 Image 中移除。Removes the specified property item from this Image.

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

旋轉、翻轉或者同時旋轉和翻轉 ImageRotates, 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)

儲存這個 Image 至指定的檔案或資料流。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)

使用指定的編碼器和影像編碼器參數,將此 Image 儲存至指定的檔案。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)

將這個 Image 以指定的格式儲存至指定的檔案。Saves this Image to the specified file in the specified format.

SaveAdd(EncoderParameters) SaveAdd(EncoderParameters) SaveAdd(EncoderParameters) SaveAdd(EncoderParameters)

將框架加入先前的 Save 方法呼叫所指定的檔案或資料流。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)

將框架加入先前的 Save 方法呼叫所指定的檔案或資料流。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)

在這個 Image 中儲存屬性項目 (中繼資料的項目)。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)

明確介面實作

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

將序列化目標物件所需的資料填入 SerializationInfoPopulates a SerializationInfo with the data needed to serialize the target object.

適用於

另請參閱