Image 類別

定義

提供功能給 BitmapMetafile 子代類別的抽象基底類別。

public ref class Image abstract : MarshalByRefObject, ICloneable, IDisposable, System::Runtime::Serialization::ISerializable
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[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
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))]
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))]
[System.Serializable]
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
[System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public abstract class Image : MarshalByRefObject, ICloneable, IDisposable, System.Runtime.Serialization.ISerializable
type Image = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter("System.Drawing.ImageConverter, System.Windows.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51")>]
type Image = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))>]
type Image = class
    inherit MarshalByRefObject
    interface ICloneable
    interface IDisposable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))>]
[<System.Serializable>]
type Image = class
    inherit MarshalByRefObject
    interface IDisposable
    interface ICloneable
    interface ISerializable
[<System.ComponentModel.TypeConverter(typeof(System.Drawing.ImageConverter))>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type Image = class
    inherit MarshalByRefObject
    interface ISerializable
    interface ICloneable
    interface IDisposable
Public MustInherit Class Image
Inherits MarshalByRefObject
Implements ICloneable, IDisposable, ISerializable
繼承
衍生
屬性
實作

範例

下列程式碼範例是設計來搭配Windows Forms使用。 它是 事件的處理常式 PaintGraphics物件會傳遞至 事件,並用來在表單上繪製影像。 此程式碼會執行下列動作:

  • 從名為 SampImag.jpg 的檔案建立映射。 此檔案必須位於與應用程式可執行檔相同的資料夾中。

  • 建立要繪製影像左上角的點。

  • 在表單上繪製未調整的影像。

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

備註

若要在 Windows Form 上繪製 Image ,請使用其中 DrawImage 一種方法。

注意

在 .NET 6 和更新版本中,只有 Windows 作業系統才支援包含此類型的 System.Drawing.Common 套件。 在跨平臺應用程式中使用此類型會導致編譯時期警告和執行時間例外狀況。 如需詳細資訊,請參閱 僅限 Windows 上支援的 System.Drawing.Common

屬性

Flags

取得這個 Image 之像素資料的屬性旗標。

FrameDimensionsList

取得 GUID 的陣列,表示這個 Image 中的框架 (Frame) 維度 (Dimension)。

Height

取得這個 Image 的高度 (單位為像素)。

HorizontalResolution

取得這個 Image 的水平解析度 (單位為每英吋的像素)。

Palette

取得或設定用於這個 Image 的調色盤。

PhysicalDimension

取得這個影像的寬度和高度。

PixelFormat

取得這個 Image 的像素格式。

PropertyIdList

取得儲存在這個 Image 中的屬性項目 ID。

PropertyItems

取得儲存在這個 Image 中的所有屬性項目 (中繼資料的各個項目)。

RawFormat

取得這個 Image 的檔案格式。

Size

取得影像的寬度和高度,單位為像素。

Tag

取得或設定物件,該物件提供影像的其他相關資料。

VerticalResolution

取得這個 Image 的垂直解析度 (單位為每英吋的像素)。

Width

取得這個 Image 的寬度 (單位為像素)。

方法

Clone()

建立這個 Image 的完全相同複本。

CreateObjRef(Type)

建立包含所有相關資訊的物件,這些資訊是產生用來與遠端物件通訊的所需 Proxy。

(繼承來源 MarshalByRefObject)
Dispose()

釋放這個 Image 所使用的所有資源。

Dispose(Boolean)

釋放 Image 所使用的 Unmanaged 資源,並選擇性地釋放 Managed 資源。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
Finalize()

允許物件在記憶體回收進行回收之前,嘗試釋放資源並執行其他清除作業。

FromFile(String)

從指定的檔案建立 Image 物件。

FromFile(String, Boolean)

使用指定之檔案中的內嵌色彩管理資訊,從該檔案建立 Image

FromHbitmap(IntPtr)

從 GDI 點陣圖控制代碼建立 Bitmap

FromHbitmap(IntPtr, IntPtr)

從 GDI 點陣圖控制代碼和 GDI 調色盤控制代碼建立 Bitmap

FromStream(Stream)

從指定的資料流建立 Image

FromStream(Stream, Boolean)

選擇性地使用指定之資料流中的內嵌色彩管理資訊,從該資料流建立 Image

FromStream(Stream, Boolean, Boolean)

選擇性地使用内嵌色彩管理資訊並驗證影像資料,從指定的資料流建立 Image

GetBounds(GraphicsUnit)

取得使用指定單位之影像的界限。

GetEncoderParameterList(Guid)

傳回指定的影像編碼器支援的參數資訊。

GetFrameCount(FrameDimension)

傳回指定維度的框架數。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetLifetimeService()
已淘汰.

擷取控制這個執行個體存留期 (Lifetime) 原則的目前存留期服務物件。

(繼承來源 MarshalByRefObject)
GetPixelFormatSize(PixelFormat)

傳回指定之像素格式的色彩深度 (單位為每像素的位元數)。

GetPropertyItem(Int32)

從這個 Image 取得指定的屬性項目。

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

傳回這個 Image 的縮圖。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
InitializeLifetimeService()
已淘汰.

取得存留期服務物件,以控制這個執行個體的存留期原則。

(繼承來源 MarshalByRefObject)
IsAlphaPixelFormat(PixelFormat)

傳回值,指示這個 Image 的像素格式是否包含 Alpha 資訊。

IsCanonicalPixelFormat(PixelFormat)

傳回值,指示像素格式是否為每像素 32 位元。

IsExtendedPixelFormat(PixelFormat)

傳回值,指示像素格式是否為每像素 64 位元。

MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
MemberwiseClone(Boolean)

建立目前 MarshalByRefObject 物件的淺層複本。

(繼承來源 MarshalByRefObject)
RemovePropertyItem(Int32)

將指定的屬性項目從這個 Image 中移除。

RotateFlip(RotateFlipType)

旋轉、翻轉或者同時旋轉和翻轉 Image

Save(Stream, ImageCodecInfo, EncoderParameters)

使用指定的編碼器和影像編碼器參數,將此影像儲存至指定的資料流。

Save(Stream, ImageFormat)

將這個影像以指定的格式儲存至指定的資料流。

Save(String)

儲存這個 Image 至指定的檔案或資料流。

Save(String, ImageCodecInfo, EncoderParameters)

使用指定的編碼器和影像編碼器參數,將此 Image 儲存至指定的檔案。

Save(String, ImageFormat)

將這個 Image 以指定的格式儲存至指定的檔案。

SaveAdd(EncoderParameters)

將框架加入先前的 Save 方法呼叫所指定的檔案或資料流。 使用這個方法以從多重框架影像儲存選取框架至另一個多重框架影像。

SaveAdd(Image, EncoderParameters)

將框架加入先前的 Save 方法呼叫所指定的檔案或資料流。

SelectActiveFrame(FrameDimension, Int32)

選取由維度和索引所指定的框架。

SetPropertyItem(PropertyItem)

在這個 Image 中儲存屬性項目 (中繼資料的項目)。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

明確介面實作

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

將序列化目標物件所需的資料填入 SerializationInfo

適用於

另請參閱