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.
ESC.
for raster graphics. But it is ESC/P2 . Which norme isGSv0
? – Stun