我有以下代码来调整单色图像的大小(因此像素值为 0[黑色] 或 255[白色])
Bitmap ResizedCharImage = new Bitmap(newwidth, newheight);
using (Graphics g = Graphics.FromImage((Image)ResizedCharImage))
{
g.CompositingQuality = CompositingQuality.HighQuality;
g.InterpolationMode = InterpolationMode.HighQualityBilinear;
g.SmoothingMode = SmoothingMode.HighQuality;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
g.DrawImage(CharBitmap, new Rectangle(0, 0, newwidth, newheight),
new Rectangle(0, 0, CharBitmap.Width, CharBitmap.Height), GraphicsUnit.Pixel);
}
我遇到的问题是,在调整大小(我正在放大图像)后,一些像素值变为 254、253、1、2 等(因此不是单色的。)我需要这不会发生.这可能吗,也许可以通过更改 Graphins 属性之一来实现?
最佳答案
使用SmoothingMode.None
关于c# - 在 C# 中调整单色图像的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2601845/