O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Draw Picture Thumbnails

Problem

You want to draw a scaled-down version of a larger image.

Solution

Use the Image.GetThumbnailImage method, and specify the size of thumbnail that you want.

Discussion

The Image class provides the built-in smarts for generating thumbnails through the GetThumbnailImage method. You simply need to pass the width and height of the thumbnail you want, and the Image class will create a new Image object that fits these criteria. Antialiasing is used when reducing the image to ensure the best possible image quality, although some blurriness and loss of detail is inevitable. In addition, you can supply a notification callback, allowing you to create thumbnails asynchronously.

The following code generates a 50-by-50-pixel thumbnail: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required