Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
GetThumbnailImage Method

Image.GetThumbnailImage Method

Returns a thumbnail for this Image object.

[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(
 int thumbWidth,
 int thumbHeight,
 Image.GetThumbnailImageAbort callback,
 IntPtr callbackData
);
[C++]
public: Image* GetThumbnailImage(
 int thumbWidth,
 int thumbHeight,
 Image.GetThumbnailImageAbort* callback,
 IntPtr callbackData
);
[JScript]
public function GetThumbnailImage(
   thumbWidth : int,
 thumbHeight : int,
 callback : Image.GetThumbnailImageAbort,
 callbackData : IntPtr
) : Image;

Parameters

thumbWidth
The width, in pixels, of the requested thumbnail image.
thumbHeight
The height, in pixels, of the requested thumbnail image.
callback
A Image.GetThumbnailImageAbort delegate. In GDI+ version 1.0, the delegate is not used. Even so, you must create a delegate and pass a reference to that delegate in this parameter.
callbackData
Must be IntPtr.Zero.

Return Value

An Image object that represents the thumbnail.

Remarks

If the Image object contains an embedded thumbnail image, then this method retrieves the embedded thumbnail and scales it to the requested size. If the Image object does not contain an embedded thumbnail image, this method creates a thumbnail image by scaling the main image.

GetThumbnailImage works well when the requested thumbnail image has a size of about 120 x 120. If you request a large thumbnail image (say 300 x 300) from an Image object that has an embedded thumbnail, there could be a noticeable loss of quality in the thumbnail image. It might be better to scale the main image (instead of scaling the embedded thumbnail) by calling DrawImage.

Example

[C#] The following example creates and displays a thumbnail image. This delegate is never called.

[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);
}
        

[Visual Basic, C++, JScript] No example is available for Visual Basic, C++, or JScript. To view a C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Image Class | Image Members | System.Drawing Namespace

Show:
© 2015 Microsoft