10.8. Show a Thumbnail for an Image

Problem

You need to show thumbnails (small representations of pictures) for the images in a directory.

Solution

Read the image from the file using the Shared FromFile method of the System.Drawing.Image class. You can then retrieve a thumbnail using the Image.GetThumbnailImage method.

How It Works

The Image class provides the functionality for generating thumbnails through the GetThumbnailImage method. You simply need to pass the width and height of the thumbnail you want (in pixels), 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. ( ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.