如何优化嵌入位图字体(有图片)的算法? [英] How to optimize the algorithm embedded bitmap fonts(have picture)?

查看:111
本文介绍了如何优化嵌入位图字体(有图片)的算法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嵌入式系统(CPU速度慢,内存有限)经常使用点阵字体,例如12 * 16的点阵可以是二进制的,请参见链接的图像.http://hi.csdn.net/attachment/201111/3/3652857_1320325279YaZf.jpg [

Embedded systems (CPU slow, limited memory) is often used dot matrix font, such as 12 * 16 dot matrix can be binary, see the linked image http://hi.csdn.net/attachment/201111/3/3652857_1320325279YaZf.jpg[^]

But this memory is memory space occupied.
How to use the appropriate algorithm to optimize, and analyse their advantages and disadvantages of the given code and the time and space complexity of algorithms?

推荐答案

没有看到链接的图像(如Medhi所说,它给出403-禁止)很难准确,但是...

它因应用程序和硬件而异.并在一定程度上满足了程序员的个人喜好.

如果您谈论的是低分辨率文本和有限的处理器,那么将字符字体存储为直接二进制可能是最好的方法:它相当紧凑(12 * 16数组中的每个字符仅需要24个字节)并且它是固定的长度,因此很容易将索引编入适当的字符以进行显示.如果您开始聪明地使用存储,则可以节省空间,甚至可以将字符存储起来,使它们在显示时变得更容易-但这在很大程度上取决于您的硬件以及处理能力-更加复杂.字符存储算法,显示字符所需的时间越长,这对于嵌入式系统来说可能是非常重要的标准-如果您错过了插槽",您将再也没有机会.

例如,我有一个嵌入式系统,用于在纸板箱沿生产线移动时在纸板箱上进行打印.打印头是垂直的,与盒子的移动成90度,分辨率相当高-180 dpi,128个单独的点.因此,我的字体存储已针对打印进行了优化:每个字符在字符的垂直切片中作为多条垂直线存储-因为我只有Z80来进行处理,并且总共有32K RAM,所以我必须快速,但密密麻麻.随着打印字符的每个垂直列的时间到来,这是清除存储区域并设置适当的黑色像素的一种简单情况.如果我以适合LCD显示器的格式存储此文件,那么它将按字节逐个水平切片,并且打印头的输出速度要慢得多.
Without seeing you linked image (as Medhi says, it gives 403 - forbidden) it is difficult to be accurate, but...

It varies, depending on the application and the hardware. And to a certain extent the programmers personal preferences.

If you are talking about low resolution text, and a limited processor, then storing character fonts as direct binary can be the best method: it is reasonably compact (each character in a 12*16 array only needs 24 bytes) and it is a fixed length, so it is simple to index to the appropriate character for display. If you start to get clever with your storage, you can save space, and even store characters in an arrangement that makes life easier when you display them - but this depends heavily on your hardware, and also on your processing power - the more complex the character storage algorithm, the longer it takes to display a character, and this may be a very important criteria of an embedded system - if you miss your "slot" you will not get the chance again.

For example, I had one embedded system for printing on cardboard cartons as they moved down a production line. The print head was vertical, at 90 degrees to the movement of the boxes, and the resolution was reasonably high - 180 dpi, 128 separate dots. So my font storage was optimized for printing: each character was stored as a number of vertical lines in a vertical slice through the character - since I only had a Z80 to do the processing, and 32K of RAM in total, I had to be quick, but densly packed. As it became time to print each vertical column of the character, it was a simple case of clear the memory area, and set the appropriate black pixels. If I had stored this in a format suitable for an LCD display, then it would have been in horizontal slices by byte, and much slower to output from the print head.


这篇关于如何优化嵌入位图字体(有图片)的算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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