| |
Sign In
public static ImageCodecInfo GetEncoderInfo(String mimeType){ int j; ImageCodecInfo[] encoders; encoders = ImageCodecInfo.GetImageEncoders(); for(j = 0; j < encoders.Length; ++j) if(encoders[j].MimeType == mimeType) return encoders[j]; return null;}public static Bitmap resizeImage(Bitmap originalImage, int max){ // never increase the size of an image from this method because it loses resolution if(originalImage.Height <= max && originalImage.Width <= max) return originalImage; int height, width; if(originalImage.Width > originalImage.Height) { width = max; height = (int)(max/((double)originalImage.Width / (double)originalImage.Height)); } else { height = max; width = (int)(max/((double)originalImage.Height / (double)originalImage.Width)); } Bitmap thumb = new Bitmap(originalImage as Image, width, height); Graphics resizer = Graphics.FromImage(thumb); resizer.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; resizer.DrawImage(originalImage, 0, 0, width, height); resizer.Dispose(); return thumb;}public static bool ThumbnailCallback(){ return false;}
Remember Me