如何将文字写入Black& C#中的白色图像 [英] How to write text to Black & White Image in C#

查看:103
本文介绍了如何将文字写入Black& C#中的白色图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在C#中将文本写入黑白图像?

How can I write text to a black and white image in C#?

推荐答案

写道:

无论如何都是在黑色&使用C#的白色图像.

Is it anyway to write text on a black & white image using C#.



动态地在图像上写文本 [



Dynamically Write Text On An Image[^]

I was able to find this article by doing a simple search of the site.


您可以将文本写成24位图像,然后将其转换为1位,如下所示:
如何将TTF字符转换为8bpp BMP文件 [
You can write the text into an 24 bit image and then convert it to 1 bit like that:
How to convert a TTF character to an 8bpp BMP file[^]


签出" .NET的Bitonal(TIFF)图像转换器".您可以从字节数组创建双色调"(即单色)图像.如何用颜色数据填充该阵列由您决定.您可以从二进制文件中加载它(也可以从图像中获取字节数组数据),也可以使用Graphics对象绘制32位图像,然后获取原始颜色数据(在字节数组中)并手动转换到1位.

从彩色转换为1位黑白时,您看到的问题很可能是由于抖动引起的.抖动旨在提高大多数自然图像(例如风景和肖像)的质量,但实际上会降低计算机生成的图像(例如文本)的质量.当您手动进行从颜色到1字节的转换时,请确保不要抖动.有关抖动的更多信息,请滚动至此Wikipedia页面的底部,并查看它们作为各种形式的示例提供的图像抖动.
Check out "Bitonal (TIFF) Image Converter for .NET". You can create a "bitonal" (i.e., monochrome) image from a byte array. How you fill that array with color data is up to you. You can load it from a bitonal file (you can also get the byte array data from an image) or you could draw a 32-bit image using a Graphics object then get the raw color data (in the byte array) and manually convert it to 1-bit.

The problem you are seeing when converting from color to 1-bit black and white is likely due to dithering. Dithering is intended to improve the quality of most natural images (e.g., scenery and portraits), but it can actually reduce the quality with computer generated images (e.g., text). When you do the manual conversion from color to 1-byte, just make sure to not dither. For more information on dithering, scroll to the bottom of this Wikipedia page and look at the images they give as examples of various forms of dithering.


这篇关于如何将文字写入Black& C#中的白色图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆