Image 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
public ref class Image abstract : MarshalByRefObject, ICloneable, IDisposable, System::Runtime::Serialization::ISerializablepublic 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.ISerializabletype 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 IDisposablePublic 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 操作系统上受支持。 在跨平台应用中使用此类型会导致编译时警告和运行时异常。 有关详细信息,请参阅 System.Drawing.Common 仅在 Windows 上受支持。
属性
| 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 的宽度(以像素为单位)。 | 
方法
显式接口实现
| ISerializable.GetObjectData(SerializationInfo, StreamingContext) | 使用将目标对象序列化所需的数据填充 SerializationInfo。 |