由网友(一个人一座城)分享简介:我在.NET中使用的图像缩放的问题。我用的是标准的显卡类型来调整图像一样在这个例子中:I have a problem with image scaling in .NET. I use the standard Graphics type to resize images like in this example:...
我在.NET中使用的图像缩放的问题。我用的是标准的显卡类型来调整图像一样在这个例子中:
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?
示例输出:
推荐答案
尝试:
graphic.CompositingMode = CompositingMode.SourceCopy;
相关推荐
最新文章