TextRenderingHint.SingleBitPerPixel 未消除条形码上的抗锯齿效果
我希望有人能提供帮助。 从 .net 打印条形码时,TextRenderingHint.SingleBitPerPixel 显然没有关闭抗锯齿功能。
下面是实际呈现条形码的代码片段:
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
graphics.DrawString(
barCodeText,
humanReadableFont,
Brushes.Black,
currentXPosition,
currentYPosition,
StringFormat.GenericTypographic);
为了在调试期间仔细检查输出,我通过“Microsoft Office Document Image Writer”打印机打印到 .tiff 格式文件。 当放大 .tiff 时,抗锯齿效果清晰可见,表现为黑色条形码条周围的灰色光环。
同样,当打印到实际打印机(HP Laser Jet 仿真模式下的 BOCA 票证打印机)时,条码会比预期更粗/显示得更粗。
我知道条形码在语法上是正确的,因为在较大的磅值下它可以扫描。 我还知道打印机能够打印至少与我要求的一样小的清晰条形码,因为在其本机“FGL”模式下,它可以打印比我的更小的清晰条形码。
我使用的字体是 Elfring Fonts Inc. 的“Code 128AB”和“Code 128AB HR”。
感谢
Joachim
I hope somebody can help. TextRenderingHint.SingleBitPerPixel is apparently not turning off antialiasing when printing a barcode from .net.
Here's a snippet of the code that actually renders the barcode:
graphics.TextRenderingHint = TextRenderingHint.SingleBitPerPixel;
graphics.DrawString(
barCodeText,
humanReadableFont,
Brushes.Black,
currentXPosition,
currentYPosition,
StringFormat.GenericTypographic);
To allow close examination of the output during debugging I'm printing to a .tiff format file through the "Microsoft Office Document Image Writer" printer. When zoomed in on the .tiff the antialiasing is clearly visible as a gray halo around the black barcode bars.
Similarly, when printing to the actual printer (BOCA ticket printer in HP Laser Jet emulation mode) the barcode bleeds/appears bolder than expected.
I know the barcode is syntactically correct because at larger point sizes it scans OK. I also know the printer is capable of printing legible barcodes at least as small as what I'm requesting because in it's native 'FGL' mode it prints legible barcodes even smaller than mine.
The fonts I'm using are "Code 128AB" and "Code 128AB HR" by Elfring Fonts Inc.
thanks
Joachim
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,最终这里出现了两个问题:
1)条形码字体的制造商没有设计要打印的字体像我试图打印的那么小。 我不是字体专家,所以我相信他们的说法。 但我并不完全相信,因为我要打印的打印机可以使用“演示”模式准确打印比这更小的条形码。
2) 我看到的“光环”效果实际上是 Windows 的“图片和传真查看器”试图让事情变得更漂亮。 当我尝试不同的软件时,条形图清晰可见。
OK, it ended up there were two problems going on here:
1) The manufacturer of the barcode font didn't design the font to be printed as small as I was trying to print. I'm no font expert, so I take their word for that. But I'm not completely convinced as the printer I was printing to could accurately print barcodes smaller than this using it's 'demo' mode.
2) The 'halo' effect I was seeing was actually Windows' "Picture and Fax Viewer" trying to make things pretty for me. When I tried different software the bars were crisp and clear.