您的位置:首页 > 大数据 > 人工智能

Image.GetThumbnailImage 方法

2006-11-02 09:00 411 查看

Image.GetThumbnailImage 方法

返回此 Image 对象的缩略图。

[Visual Basic]
Public Function GetThumbnailImage( _
ByVal thumbWidth As Integer, _
   ByVal thumbHeight As Integer, _
   ByVal callback As Image.GetThumbnailImageAbort, _
   ByVal callbackData As IntPtr _
) As Image
[C#]
public Image GetThumbnailImage(
intthumbWidth,
intthumbHeight,
Image.GetThumbnailImageAbortcallback,
IntPtrcallbackData
);
[C++]
public: Image* GetThumbnailImage(
intthumbWidth,
intthumbHeight,
Image.GetThumbnailImageAbort* callback,
IntPtrcallbackData
);
[JScript]
public function GetThumbnailImage(
thumbWidth : int,
thumbHeight : int,
callback : Image.GetThumbnailImageAbort,
callbackData : IntPtr
) : Image;

参数

thumbWidth 请求的缩略图的宽度(以像素为单位)。 thumbHeight 请求的缩略图的高度(以像素为单位)。 callback 一个 Image.GetThumbnailImageAbort 委托。在 GDI+ 1.0 版中不使用此委托。即便如此,也必须创建一个委托并在该参数中传递对此委托的引用。 callbackData 必须是 IntPtr.Zero。

返回值

用于表示该缩略图的 Image 对象。

备注

如果 Image 对象包含一个嵌入式缩略图像,则此方法会检索嵌入式缩略图,并将其缩放为所需大小。如果 Image 对象不包含嵌入式缩略图像,此方法会通过缩放主图像创建一个缩略图像。

当所请求的缩略图大小约为 120×120 时,GetThumbnailImage 工作正常。如果从一个有嵌入式缩略图的 Image 对象中请求一个较大的缩略图像(比如 300×300),则在缩略图像的质量会有显著的降低。通过调用 DrawImage 缩放主图像(而非嵌入式缩略图),则效果可能较好。

示例

[C#] 下面的示例创建并显示一个缩略图图像。从不调用此委托。

[C#]
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);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐