【发布时间】:2012-05-02 15:48:43
【问题描述】:
这似乎是转换位图像素格式的标准方法,但在转换为黑白格式时效果很差:
// convert to black & white bitmap
FormatConvertedBitmap monoBitmap = new FormatConvertedBitmap(bitmap, PixelFormats.BlackWhite, null, 0);
// save black & white bitmap to file
fileName = string.Format("{0}.bmp", data.SelectedProduct.Code);
bitmapEncoder = new BmpBitmapEncoder();
bitmapEncoder.Frames.Add(BitmapFrame.Create(monoBitmap));
using (Stream stream = File.Create(fileName))
{
bitmapEncoder.Save(stream);
}
生成的图像文件非常粗糙且像素化。我需要将它发送到行式打印机,所以我需要锋利的边缘。
转换前的原件看起来不错(它的 32BPP 颜色),如果我使用 IrfanView 之类的工具将原件手动转换为黑白,它的效果也比 .NET 所做的要好得多。
在 .NET 中是否有另一种替代方法来代替 FormatConvertedBitmap?
【问题讨论】:
-
你检查我的答案了吗?让我知道这是否是您想要实现的目标。