ESC POS command ESC* for printing bit image on printer
Asked Answered
E

1

5

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

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.

Enrica answered 22/5, 2017 at 7:39 Comment(0)
H
15

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.

Print multiple lines using ESC *

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

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.

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.

Print the entire image with GS v 0

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).

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.

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.

Herrick answered 27/5, 2017 at 2:36 Comment(3)
The Doc says there is also ESC. for raster graphics. But it is ESC/P2 . Which norme is GSv0 ?Stun
C# version: #60137321Serafinaserafine
NodeJS version: github.com/song940/node-escpos/blob/v3/packages/printer/…Serafinaserafine

© 2022 - 2024 — McMap. All rights reserved.