I have a problem with image scaling in .NET. I use the standard Graphics type to resize images like in this example:
public static Image Scale(Image sourceImage, int destWidth, int destHeight)
{
Bitmap toReturn = new Bitmap(sourceImage, destWidth, destHeight);
toReturn.SetResolution(sourceImage.HorizontalResolution, sourceImage.VerticalResolution);
using (Graphics graphics = Graphics.FromImage(toReturn))
{
graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.DrawImage(sourceImage, 0, 0, destWidth, destHeight);
}
return toReturn;
}
But I have a big problem with resized images: they have gray and black borders and it's extremely important to make have images without them.
Why do they appear and what I can to do make them disappear?
Sample Output:
image 370x370: http://www.freeimagehosting.net/image.php?a3be1bc837.jpg