. Net is another method for generating thumbnails, which is not deformed and is very easy to use. net thumbnails
Generating thumbnails is a very common function. I found a method to rewrite some code, which is practical and useful.. net also generates thumbnails without deformation.
1 /// <summary> 2 /// create a thumbnail for the image. Why? 3 /// </summary> 4 /// <param name = "phyPath"> original image path of </param> 5 /// <param name = "width"> thumbnail width </param> 6 /// <param name = "height"> thumbnail height </ param> 7 // <returns> </returns> 8 public System. drawing. image GetHvtThumbnail (System. drawing. image image, int width, int height) 9 {10 // The code is 11. // For more information, see: http://hovertree.com/menu/hovertreecms/12 Bitmap m_hovertreeBmp = new Bitmap (width, height); 13 // create a System from Bitmap. drawing. graphics 14 Graphics m_HvtGr = Graphics. fromImage (m_hovertreeBmp); 15 // set 16 m_HvtGr.SmoothingMode = System. drawing. drawing2D. smoothingMode. highQuality; 17 // The following is also set to high quality 18 m_HvtGr.CompositingQuality = System. drawing. drawing2D. compositingQuality. highQuality; 19 // set this to High 20 m_HvtGr.InterpolationMode = System. drawing. drawing2D. interpolationMode. highQualityBicubic; 21 // draw the original image as the scaled down figure 22 Rectangle rectDestination = new Rectangle (0, 0, width, height); 23 24 int m_width, m_height; 25 if (image. width * height> image. height * width) 26 {27 m_height = image. height; 28 m_width = (image. height * width)/height; 29} 30 else31 {32 m_width = image. width; 33 m_height = (image. width * height)/width; 34} 35 36 m_HvtGr.DrawImage (image, rectDestination, 0, 0, m_width, m_height, GraphicsUnit. pixel); 37 38 return m_hovertreeBmp; 39}