Dot-Matrix Graphics
Dot-matrix printers typically have the capability of reproducing raster graphics images. Three numeric capabilities and three string capabilities help a program draw raster-graphics images independent of the type of dot-matrix printer or the number of pins or dots the printer can handle at one time.
| Dot-Matrix Graphics | |
|---|---|
npins
spinv spinh porder sbim rbim |
Number of pins, N, in print-head
Spacing of pins vertically in pins per inch Spacing of dots horizontally in dots per inch Matches software bits to print-head pins Start printing bit image graphics, B bits wide End printing bit image graphics |
The sbim sring is used with a single argument, B, the width of the image in dots.
The model of dot-matrix or raster-graphics that terminfo presents is similar to the technique used for most dot-matrix printers: each pass of the printer's print-head is assumed to produce a dot-matrix that is N dots high and B dots wide. This is typically a wide, squat, rectangle of dots. The height of this rectangle in dots will vary from one printer to the next; this is given in the npins numeric capability. The size of the rectangle in fractions of an inch will also vary; it can be deduced from the spinv and spinh numeric capabilities. With these three values an application can divide a complete raster-graphics image into several horizontal strips, perhaps interpolating to account for different dot spacing vertically and horizontally.
The sbim and rbim strings
start and end a dot-matrix image, respectively. The sbim string
is used with a single argument that gives the width of the dot-matrix
in dots. A sequence of image-data bytes
are sent to the printer
after the sbim string and before the rbim string. The number of bytes is a integral multiple
of the width of the dot-matrix; the multiple and the form of each
byte is determined by the porder string as described
below.
The porder string is a comma separated list
of pin numbers optionally followed by an numerical offset. The offset,
if given, is separated from the list with a semicolon. The position
of each pin number in the list corresponds to a bit in an 8-bit data
byte. The pins are numbered consecutively from 1 to npins,
with 1 being the top pin. Note that the term pin
is used loosely
here; ink-jet
dot-matrix printers don't have pins, but can
be considered to have an equivalent method of applying a single dot
of ink to paper. The bit positions in porder are
in groups of 8, with the first position in each group the most significant
bit and the last position the least significant bit. An application
produces 8-bit bytes in the order of the groups in porder.
An application computes the image-data bytes
from the internal
image, mapping vertical dot positions in each print-head pass into
8-bit bytes, using a 1 bit where ink should be applied and 0 where
no ink should be applied. This can be reversed (0 bit for ink, 1 bit
for no ink) by giving a negative pin number. If a position is skipped
in porder, a 0 bit is used. If a position has
a lower case ‘x’ instead of a pin number, a 1 bit is used
in the skipped position. For consistency, a lower case ‘o’
can be used to represent a 0 filled, skipped bit. There must be a
multiple of 8 bit positions used or skipped in porder;
if not, low-order bits of the last byte are set to 0. The offset,
if given, is added to each data byte; the offset can be negative.
Some examples may help clarify the use of the porder string. The AT&T; 470, AT&T; 475 and C.Itoh 8510 printers provide eight pins for graphics. The pins are identified top to bottom by the 8 bits in a byte, from least significant to most. The porder strings for these printers would be 8,7,6,5,4,3,2,1. The AT&T; 478 and AT&T; 479 printers also provide eight pins for graphics. However, the pins are identified in the reverse order. The porder strings for these printers would be 1,2,3,4,5,6,7,8. The AT&T; 5310, AT&T; 5320, Digital LA100, and Digital LN03 printers provide six pins for graphics. The pins are identified top to bottom by the decimal values 1, 2, 4, 8, 16 and 32. These correspond to the low six bits in an 8-bit byte, although the decimal values are further offset by the value 63. The porder string for these printers would be ,,6,5,4,3,2,1;63, or alternately o,o,6,5,4,3,2,1;63.