The following MakeThumbnail extension method creates a thumbnail file for an image:
// Make a thumbnail for the file with maximum// dimensions maxWidth x maxHeight.private Bitmap MakeThumbnail(string filename, int maxWidth, int maxHeight){ // Load the image. Bitmap bm = LoadImageWithoutLocking(filename); // Calculate the scale. float xscale = maxWidth / (float)bm.Width; float yscale = maxHeight / (float)bm.Height; float scale = Math.Min(xscale, yscale); // Make the thumbnail's bitmap. int width = (int)Math.Round(bm.Width * scale); int height = (int)Math.Round(bm.Height * scale); Bitmap thumbnail = new Bitmap(width, height); using (Graphics gr = Graphics.FromImage(thumbnail)) { gr.InterpolationMode = InterpolationMode.High; ...