Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void GenereMiniature(Stream st, string directory, string filename, int Height)
- {
- Bitmap thumbIndex = new Bitmap(st);
- int oldWidth = thumbIndex.Width;
- int oldHeight = thumbIndex.Height;
- double coeff = Convert.ToDouble(oldWidth) / Convert.ToDouble(oldHeight);
- int newHeight = Height;
- int newWidth = Convert.ToInt32(newHeight * coeff);
- Size ThumbnailsSize = new Size(newWidth, newHeight);
- Image oImg = Image.FromStream(st);
- Image oThumbNail = new Bitmap(ThumbnailsSize.Width, ThumbnailsSize.Height);
- Graphics oGraphic = Graphics.FromImage(oThumbNail);
- oGraphic.CompositingQuality = CompositingQuality.HighQuality;
- oGraphic.SmoothingMode = SmoothingMode.HighQuality;
- oGraphic.InterpolationMode = InterpolationMode.HighQualityBicubic;
- Rectangle oRectangle = new Rectangle(0, 0, newWidth, newHeight);
- oGraphic.DrawImage(oImg, oRectangle);
- oGraphic.Dispose();
- oImg.Dispose();
- oThumbNail.Save(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, directory + filename));
- }
Add Comment
Please, Sign In to add comment