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 窗体 一起使用。 它是事件的处理程序 Paint 。 对象 Graphics 将传递给 事件,并用于在窗体上绘制图像。 此代码执行以下操作:

  • 从名为 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 窗体上绘制 Image ,请使用方法之 DrawImage 一。

备注

在 .NET 6 及更高版本中, System.Drawing.Common 包(包括此类型)仅在 Windows 操作系统上受支持。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 仅在 Windows 上支持 System.Drawing.Common

属性

Flags

获取该 Image 的像素数据的特性标志。

FrameDimensionsList

获取 GUID 的数组,这些 GUID 表示此 Image 中帧的维数。

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)

创建一个对象,该对象包含生成用于与远程对象进行通信的代理所需的全部相关信息。

(继承自 MarshalByRefObject)
Dispose()

释放此 Image 使用的所有资源。

Dispose(Boolean)

释放由 Image 占用的非托管资源,还可以另外再释放托管资源。

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()
已过时.

检索控制此实例的生存期策略的当前生存期服务对象。

(继承自 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

适用于

另请参阅