beautypg.com

Datamax-O'Neil PrintPAD AN-05 (LP) User Manual

An-05 (lp)

background image






AN-05 (LP)

September 23, 2005


HOW TO PRINT RLE COMPRESSED GRAPHICS IN LINE PRINTER MODE

Overview
The O’Neil printers have several graphics modes that allow graphics to either be stored in the printer’s Flash and printed
repeatedly upon demand (useful for logos or icons), or sent to the printer and printed one time only (useful for signatures
or transient images). Graphics sent to be printed one time only can be sent in their full bitmap form, or they can be
compressed using a Run Length Encoding scheme (RLE). This document describes how to encode a graphic image
using RLE.

Graphic images are formed of line after line of individual dots, like tiny slices across the image. For the O’Neil printers,
each of those lines is .005” tall, and each dot is .005” wide. A single byte then can represent an area only .005 inches tall
and .040 inches wide (8 dots). It takes approximately 5000 bytes to represent a single square inch of graphic data. But
most images contain large white or black areas. For example, a signature is mainly white space. Since this white space
data is the same byte repeated, over and over, large horizontal areas across one dotline can be compressed into only two
bytes – one byte contains the graphics information and the second byte contains the number of times that byte is
repeated (called Run Length Encoding or RLE). A similar technique can compress multiple horizontal white lines into only
two bytes – one of which is a command to advance paper and the other is the number of lines to advance. Using these
techniques, the total data is usually reduced to ½ or less of its original size (many signatures can come down to 1/3 to ¼
of their original size). RLE does not compress well when the graphic is very “busy”. So the O’Neil implementation allows
the application to determine on a DOTLINE BY DOTLINE basis whether the line is best sent using compression or not.


Compressing the image using RLE
All RLE images begin with the two-character escape sequence ESC B (0x1B, 0x42) and end with the two-character
escape sequence ESC E (0x1B, 0x45). If a series of dotlines are all whitespace, the vertical white space can be
compressed by sending a two-character sequence consisting of an ‘A’ (0x41) followed by a single byte containing the
number of blank dotlines to advance. Each non white-space dotline must represent enough bytes for the total width of the
printer (4” is 832 bits or 104 bytes, 3” is 576 bits or 72 bytes, and 2” are 384 bits or 48 bytes). The first bit printed is the
MSbit of the first byte received. Each dotline is preceded by a ‘U’ (0x55) if that dotline is sent Uncompressed, or a ‘G’
(0x47) if that dotline is sent Compressed. If the dotline is compressed, then that dotline will consist of a series of byte
pairs after the G. The first byte in the pair is the graphics byte; the second byte is the number of times to repeat that byte.

The following example will show how a simple, contrived image can be compressed. We will use a mythical printhead
that is 20 bytes wide and a graphics image 10 dotlines tall (200 bytes total before compression. Each pair below
represents one byte in Hex of our graphic:


00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 0F 80 00 00 00 00 FF FF D2 00 00 00 00 00 00 00
00 00 00 0F FF FF C2 00 00 78 45 45 D2 D2 D2 F9 F9 00 00 00
00 0F F8 00 0E E0 00 00 FF FF 01 E0 FF D2 00 88 73 FC C7 00
00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
00 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This manual is related to the following products: