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
Standard 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;
}

Tags:

Updated:

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.

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.

Leave a Comment

Your email address will not be published. Required fields are marked *

Loading...