用于在打印机上打印位图

用于在打印机上打印位图

本文介绍了ESC POS命令ESC *用于在打印机上打印位图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用ESC POS命令ESC *打印位图徽标文件.以下是该命令的技术文档的链接.

I want to print a bitmap logo file with ESC POS command ESC*.Following is the link for technical documentation of the command.

https://reference.epson-biz.com/modules/ref_escpos/index.php?content_id=88

据我说,打印机需要1s和0s形式的图像数据.因此,它打印一个点(出现为1)和空白(出现为0).但由于上述命令仅在水平方向上接受图像数据,因此我无法通过上述命令弄清楚如何发送多行位图像数据.请帮我解决这个问题.

According to me, the printer requires the image data in the form of 1s and 0s. So, it prints a dot, with the occurrence of 1 and blank, with the occurrence of 0.But I am not able to figure out how to send multi line bit image data with the help of above command, since the command accepts only the image data in the horizontal direction. Please help me with the problem.

推荐答案

ESC *是ESC/POS中几个位图"命令之一.它接受列格式"数据,该数据只能代表8像素或24像素的单行.因此,这里有两个不错的选择.

ESC * is one of several "bit image" commands in ESC/POS. It accepts "column format" data, which can only represent a single line of either 8 or 24 pixels. So there are two good options here.

听起来您可以打印一行,所以我认为数据格式本身不是问题.

It sounds like you are able to print one line, so I will assume that the data format itself is not an issue.

您可以通过简单地重复命令以打印多余的行(用换行符\n分隔)来打印多行.这需要将图像切碎,并用空格填充,以使它的高度为8或24像素的倍数(同样,由于格式).

You can print multiple lines by simply repeating the command to print the extra lines, separated by line breaks \n. This requires chopping up the image, and padding it with whitespace so that it is a multiple of 8 or 24 pixels in height (again, due to the format).

由于行距,您需要发出一个命令来更改图像打印过程中换行的大小,然后发出另一个命令以在最后将它们重置.

Because of line spacing, you need to issue a command to change the size of line feeds during the image print, then another command to reset them at the end.

我将ESC 3 0x10用于16个单位的换行符(字节0x1b 0x33 0x10)和ESC 2(字节0x1b 0x32)进行重置.

I use ESC 3 0x10 for 16-unit line feeds (bytes 0x1b 0x33 0x10) and ESC 2 (bytes 0x1b 0x32) to reset.

这种打印方法与旧打印机具有出色的兼容性,但是您可以在输出中得到一些细的水平线.

This method of printing has excellent compatibility with old printers, but you can get some thin horizontal lines in the output.

此位图命令接受不同的栅格格式"数据.我利用了这样一种事实,即这种格式的blob与广泛实施的 PBM 中的二进制数据相同. a>位图格式(特别是带有P4标头的文件中的二进制数据).

This bit image command accepts the different "raster format" data. I make use of the fact that the blob in this format is identical to the binary data in the widely implemented PBM bitmap format (specifically the binary data in files with the P4 header).

图像的高度将受到打印缓冲区大小的限制,但可能会增加到65535像素.由于存在宽度,宽度必须被8整除.

The height of the image will be limited by your print buffer size, but could go up to 65535 pixels. The width must be divisible by 8 because of the representation.

旁注::这些片段摘录了现在出现在流行的开源 escpos-php python-escpos 库.使用现有库有很多好处,如果可以选择,则应考虑使用它.

Side note: These snippets the actual prototypes of the image processing code that now appears in the popular open source escpos-php and python-escpos libraries. Using an existing library has a number of benefits, and you should consider it if it's an option.

这篇关于ESC POS命令ESC *用于在打印机上打印位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 07:12