語言

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 方法來縮放主影像(而不是縮放嵌入縮圖)會更好。

適用於