.Text and Image quality
I don’t know what others think, but IMHO the quality of the preview images generated by .Text isn’t as good as it could be. Currently it just resizes the images with the simplest algorithm existing in the .NET framework.
Therefore, I’ve patched the sources, so it will use bicubic interpolation. Here’s a comparison:
Previous resizing | Bicubic resizing |
---|---|
Maybe Scott wants to commit my changes to his sources, so here’s what I did: The image conversion happens in the method MakeAlbumImages
in Dottext.Framework.Images
. I’ve added another method which does the resizing, and added the calls to it in the original method. Following the affected code snippet, I’ve marked my changes bold:
public static void MakeAlbumImages(ref Dottext.Components.Image _image)
{
System.Drawing.Image original = System.Drawing.Image.FromFile(_image.OriginalFilePath);
Size _newSize = ResizeImage(original.Width,original.Height,640,480);
_image.Height = _newSize.Height;
_image.Width = _newSize.Width;
System.Drawing.Image displayImage = ResizeImage(original,_newSize);
System.Drawing.Image tbimage = ResizeImage(original, ResizeImage(original.Width,original.Height,120,120));
original.Dispose();
displayImage.Save(_image.ResizedFilePath, GetFormat(_image.File));
displayImage.Dispose();
tbimage.Save(_image.ThumbNailFilePath,ImageFormat.Jpeg);
tbimage.Dispose();
}
private static System.Drawing.Image ResizeImage(System.Drawing.Image original, Size newSize)
{
System.Drawing.Image result = newBitmap(newSize.Width, newSize.Height);
using(Graphics g = Graphics.FromImage(result))
{
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.DrawImage(original, 0, 0, newSize.Width, newSize.Height);
}
return result;
}
Comments
Nick Ryberg
That patch looks great - I hope it gets implemented.
I was wondering why thumbnails looked so edgy in the basic gallery implementation.
Scott Galloway
Yup, just joined the list yesterday…good to know.
Marcus
But then there’s the performance hit for bicubic operations! Can of worms… Might benefit from an option to choose on a image by image basis, defaulting to the fast original version.
Jason Alexander
Very nice, Thomas!
We’ll be applying this same patch to nGallery, as well! Thanks for the great info!
Dave Burke
Just want to say nice work, Thomas! Quite a difference in quality.
Scott Galloway
Nice one…patched. Do you plan on submitting this to Scott W. for oinclusion in V. Next?
Thomas Freudenberg
Marcus, for a blog with a few users only, I don’t think that bicubic resizing will hurt the performance. Not all of them will upload pictures concurrently. A server like weblogs.asp.net it may by different ;-)
Thomas Freudenberg
As far as I can see you’ve subscribed to the .Text mailing list (http://aspadvice.com/SignUp/list.aspx?l=153&c=25). Grant Carpenter answered to my proposal Thursday:
“No big deal, we can figure out what it does before adding it, the images look great. I’ll see if I can get it into the source in the next few days.”
Leave a Comment
Your email address will not be published. Required fields are marked *