[Mono-aspnet-list] SmoothingMode.Antialias problem

kalljoel kalljoel at gmail.com
Mon Jan 4 08:07:41 EST 2010


Hi!

I'm using Mono to resize images on a web server. Unfortunately the quality
is not what it should be, the rendered image is pixelated, though I use
HighQualityCubic interpolation mode and SmoothingMode.AntiAlias. Using the
same code on windows gives me better results.

This is my code.

------------
returnImg = new Bitmap(fullSizeImg, size, Convert.ToInt32(origHeight *
((float)size / (float)origWidth)));

Graphics oGraphics = Graphics.FromImage(returnImg);
oGraphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
oGraphics.SmoothingMode = SmoothingMode.AntiAlias;

oGraphics.DrawImage(fullSizeImg, 0, 0, size, Convert.ToInt32(origHeight *
((float)size / (float)origWidth)));
oGraphics.Dispose();

ImageCodecInfo info = null;

ImageCodecInfo[] encoderInfoArray = ImageCodecInfo.GetImageEncoders();
foreach (ImageCodecInfo imageCodecInfo in encoderInfoArray)
{
    if (0 == String.Compare("image/png", imageCodecInfo.MimeType, true))
    {
        info = imageCodecInfo;
    }
}

if (info != null)
{

    EncoderParameters encParams = new EncoderParameters(1);
    long quality = 95;
    encParams.Param[0] = new
EncoderParameter(System.Drawing.Imaging.Encoder.Quality,quality);

    returnImg.Save(Response.OutputStream, info, encParams);
}
----------------
-- 
View this message in context: http://old.nabble.com/SmoothingMode.Antialias-problem-tp27002758p27002758.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.



More information about the Mono-aspnet-list mailing list