private void GenerateThumbnails(double scaleFactor, Stream sourcePath,string targetPath) { using (var image = System.Drawing.Image.FromStream(sourcePath)) { // can given width of image as we want var newWidth = (int)(image.Width * scaleFactor); // can given height of image as we want var newHeight = (int)(image.Height * scaleFactor); var thumbnailImg = new Bitmap(newWidth, newHeight); var thumbGraph = Graphics.FromImage(thumbnailImg); thumbGraph.CompositingQuality = CompositingQuality.HighQuality; thumbGraph.SmoothingMode = SmoothingMode.HighQuality; thumbGraph.InterpolationMode = InterpolationMode.HighQualityBicubic; var imageRectangle = new Rectangle(0, 0, newWidth, newHeight); thumbGraph.DrawImage(image, imageRectangle); thumbnailImg.Save(targetPath, image.RawFormat); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)