public static void SaveThumbnailImage(int width, int height, Bitmap image, ImageFormat newFormat, Stream thumbOut, ImageFilter filter) { ThumbMaker thumb = new ThumbMaker(image, newFormat); if (newFormat == ImageFormat.Jpeg) { //note: supports high quality JPEG thumbnailing thumb.ResizeToJpeg(width, height, JPEG_QUALITY, thumbOut, filter); } else if (newFormat == ImageFormat.Gif) { //note: supports transparent images thumb.ResizeToGif(width, height, thumbOut, filter); } else if (newFormat == ImageFormat.Png) { //note: nothing special needs to be done here since PNG format rules! thumb.ResizeToPng(width, height, thumbOut, filter); } else if (newFormat == ImageFormat.Bmp) { thumb.ResizeToBmp(width, height, thumbOut, filter); } else { throw new Exception("unsupported image format detected"); } }
/// <summary> /// Resizes the GIF. /// </summary> /// <param name="image">The image.</param> /// <param name="size">The size.</param> /// <returns></returns> private Bitmap ResizeGif(Bitmap image, Size size) { if (image.Size == size) { return(image); } ThumbMaker maker = new ThumbMaker(image); return(maker.ResizeToGif(size)); }
/// <summary> /// Resizes the GIF. /// </summary> /// <param name="image">The image.</param> /// <param name="size">The size.</param> /// <returns></returns> private Bitmap ResizeGif(Bitmap image, Size size) { if (image.Size == size) { return image; } ThumbMaker maker = new ThumbMaker(image); return maker.ResizeToGif(size); }