形成字母出二进制数组 [英] forming letters out of binary arrays
问题描述
我需要创建一个将得到一个字母数字字母作为parametter并返回一个N×M的大小二进制数组的函数,其中1和0将形成给出的信。
I need to create a function that would receive an alphanumeric letter as parametter and return a NxM sized binary array, in which 1's and 0's would form the letter given.
例如,字母A和B,该阵列可以是这样的:
For example, for letter A and B, the arrays could look like this:
00000110000 11111111100
00001001000 11000000011
00011001100 11000000011
00111111100 11111111110
01100000110 11000000011
11000000011 11000000011
11000000011 11000000011
11000000011 11111111111
的提示:如果您STRETCH时你的眼睛可以看到的字母会好一点的
我知道如何做到这一点的唯一方法是通过为每个字符手动创建数组并将其插入到交换机情况。这似乎是非常枯燥和不专业的。
The only way I know how to do this is by manually creating arrays for each character and insert them into switch-case. Which seems extremely dull and unprofessional.
有没有人有更好的主意吗?
Does anyone have a better idea?
推荐答案
我已经回答过类似的问题<一href=\"http://stackoverflow.com/questions/22881312/c-sharp-drawing-text-using-custom-pixels/22881391#22881391\">here.
I have answered a similar question here.
在OP有想画圈圈作为他的自定义像素。
The OP there wanted to draw circles as his 'custom pixels'.
这样做是为了吸引你想要的文字在大小和字体你喜欢上一个(不可见),位图,然后从中读取像素集合,并将它们在你的自定义像素写的,即你的数字。
The idea is to draw the Characters you want in the size and font you like onto an (invisible) bitmap and then read the set pixels from it and write them in your 'custom pixels', i.e. your digits.
这听起来有点吓人,但如果你看看code提供你会发现它实际上是相当简单的,它工作得很好!
It may sound a bit daunting, but if you look at the code provided you'll see that it really is rather straightforward and it works quite well!
这篇关于形成字母出二进制数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!