调整,如MS画图中的位图 - 无抗锯齿 [英] Resize a bitmap like MS Paint - no antialiasing
本文介绍了调整,如MS画图中的位图 - 无抗锯齿的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我用这个方法来调整位图:
私人位图ResizeBitmap(位图B,INT nWidth,INT nHeight参数)
{
位图的结果=新位图(nWidth,nHeight参数);使用
(图形G = Graphics.FromImage((图)结果))
{
g.SmoothingMode = SmoothingMode.None;
g.DrawImage(B,0,0,nWidth,nHeight参数);
}
返回结果;
}
它仍然使用抗锯齿即使我指定的:
g.SmoothingMode = SmoothingMode.None;
我只想没有任何平滑基本的调整大小。
解决方案
<而不是做 的p>
g.SmoothingMode = SmoothingMode.None;
你应该做的。
g.InterpolationMode = InterpolationMode.NearestNeighbor;
When I use this method to resize a bitmap:
private Bitmap ResizeBitmap(Bitmap b, int nWidth, int nHeight)
{
Bitmap result = new Bitmap(nWidth, nHeight);
using (Graphics g = Graphics.FromImage((Image)result))
{
g.SmoothingMode = SmoothingMode.None;
g.DrawImage(b, 0, 0, nWidth, nHeight);
}
return result;
}
It still uses antialiasing even though I specified:
g.SmoothingMode = SmoothingMode.None;
I want just a basic resizing without any smoothing.
解决方案
Instead of doing
g.SmoothingMode = SmoothingMode.None;
you should do
g.InterpolationMode = InterpolationMode.NearestNeighbor;
这篇关于调整,如MS画图中的位图 - 无抗锯齿的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文