ESC POS 命令 ESC* 用于在打印机上打印位图 [英] ESC POS command ESC* for printing bit image on printer

查看:125
本文介绍了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

据我所知,打印机需要 1 和 0 形式的图像数据.因此,它打印一个点,出现 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.

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

You can print multiple lines by simply repeating the command to print the extra lines, separated by line breaks . 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(字节 0x1b0x32) 重置.

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 位图格式(特别是带有 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-phppython-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* 用于在打印机上打印位图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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