语言

Image.GetThumbnailImage 方法

定义

返回此 Image缩略图。

public:
 System::Drawing::Image ^ GetThumbnailImage(int thumbWidth, int thumbHeight, System::Drawing::Image::GetThumbnailImageAbort ^ callback, IntPtr callbackData);
public System.Drawing.Image GetThumbnailImage(int thumbWidth, int thumbHeight, System.Drawing.Image.GetThumbnailImageAbort? callback, IntPtr callbackData);
public System.Drawing.Image GetThumbnailImage(int thumbWidth, int thumbHeight, System.Drawing.Image.GetThumbnailImageAbort callback, IntPtr callbackData);
member this.GetThumbnailImage : int * int * System.Drawing.Image.GetThumbnailImageAbort * nativeint -> System.Drawing.Image
Public Function GetThumbnailImage (thumbWidth As Integer, thumbHeight As Integer, callback As Image.GetThumbnailImageAbort, callbackData As IntPtr) As Image

参数

thumbWidth
Int32

所请求缩略图的宽度(以像素为单位)。

thumbHeight
Int32

所请求缩略图的高度(以像素为单位)。

callback
Image.GetThumbnailImageAbort

委托 Image.GetThumbnailImageAbort 。

注意 必须创建委托并将对委托的引用作为 callback 参数传递,但未使用委托。

callbackData
IntPtr

nativeint

必须是 Zero。

返回

表示缩略图的一个 Image 。

示例

下面的代码示例创建并显示缩略图。 从不调用此委托。

public bool ThumbnailCallback()
{
    return false;
}
public void Example_GetThumb(PaintEventArgs e)
{
    Image.GetThumbnailImageAbort myCallback =
    new Image.GetThumbnailImageAbort(ThumbnailCallback);
    Bitmap myBitmap = new Bitmap("Climber.jpg");
    Image myThumbnail = myBitmap.GetThumbnailImage(
    40, 40, myCallback, IntPtr.Zero);
    e.Graphics.DrawImage(myThumbnail, 150, 75);
}

Public Function ThumbnailCallback() As Boolean 
  Return False 
End Function 

Public Sub Example_GetThumb(ByVal e As PaintEventArgs) 
    Dim myCallback As New Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback) 
    Dim myBitmap As New Bitmap("Climber.jpg") 
    Dim myThumbnail As Image = myBitmap.GetThumbnailImage(40, 40, myCallback, IntPtr.Zero) 
    e.Graphics.DrawImage(myThumbnail, 150, 75) 
End Sub

注解

Image如果包含嵌入的缩略图图像,此方法将检索嵌入的缩略图,并将其缩放到请求的大小。 Image如果不包含嵌入的缩略图图像,此方法通过缩放主图像来创建缩略图图像。

当请求的缩略图图像的大小约为 120 x 120 像素时,此方法 GetThumbnailImage 非常有效。 如果从 Image 具有嵌入式缩略图的缩略图请求大型缩略图(例如 300 x 300),则缩略图图像中的质量可能会明显丢失。 最好通过调用 DrawImage 方法缩放主图像(而不是缩放嵌入缩略图)。

适用于