Image.GetThumbnailImage(Int32, Int32, Image+GetThumbnailImageAbort, IntPtr) 方法


返回此 Image 的缩略图。Returns a thumbnail for this Image.

 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



请求的缩略图的宽度(以像素为单位)。The width, in pixels, of the requested thumbnail image.


请求的缩略图的高度(以像素为单位)。The height, in pixels, of the requested thumbnail image.


一个 Image.GetThumbnailImageAbort 委托。A Image.GetThumbnailImageAbort delegate.

注意,必须创建一个委托并将对此委托的引用作为 callback 参数传递,但此委托不会被使用。Note You must create a delegate and pass a reference to the delegate as the callback parameter, but the delegate is not used.


必须为 ZeroMust be Zero.


表示缩略图的 ImageAn Image that represents the thumbnail.


下面的代码示例创建并显示缩略图。The following code example creates and displays a thumbnail image. 永远不会调用此委托。This delegate is never called.

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如果包含嵌入的缩略图,此方法将检索嵌入的缩略图,并将其缩放为请求的大小。If the Image contains an embedded thumbnail image, this method retrieves the embedded thumbnail and scales it to the requested size. Image如果不包含嵌入的缩略图,此方法将通过缩放主图像来创建缩略图。If the Image does not contain an embedded thumbnail image, this method creates a thumbnail image by scaling the main image.

GetThumbnailImage请求的缩略图的大小约为 120 x 120 像素时,此方法非常有效。The GetThumbnailImage method works well when the requested thumbnail image has a size of about 120 x 120 pixels. 如果从具有嵌入式缩略图的中Image请求较大的缩略图(例如,300 x 300),则缩略图图像可能会出现明显的质量损失。If you request a large thumbnail image (for example, 300 x 300) from an Image that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. 通过调用DrawImage方法,可以更好地缩放主图像(而不是缩放嵌入的缩略图)。It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling the DrawImage method.