From Wikipedia, the free encyclopedia
Jump to: navigation, search
The Wikipedia logo converted to Sixel format and rendered in an xterm with VT340 emulation.

Sixel, short for "six pixels", is a bitmap graphics format supported by terminals and printers from DEC. It consists of a pattern six pixels high and one wide, resulting in 64 possible patterns. Each possible pattern is assigned an ASCII character, making the sixels easy to transmit on 7-bit serial links.

Sixel was first introduced as a way of sending bitmap graphics to DEC dot matrix printers like the LA50. After being put into "sixel mode" the following data was interpreted to directly control six of the pins in the nine-pin print head. A string of sixel characters encodes a single 6-pixel high row of the image.

The system was later re-used as a way to send bitmap data to the VT200 series terminals as a way to define custom character sets. A number of sixels were used to define each character. Starting with the VT300 series, the terminals could decode a complete sixel image to the screen, like those previously sent to printers.


Sixel encodes images by breaking up the bitmap into a series of 6-pixel high horizontal strips. Each 1-pixel-wide vertical column in a particular strip forms a single sixel. Each sixel's pixels are read as binary and encoded into a single 6-bit number, with "on" pixels encoded as a 1. This number, from 0 to 63 decimal, is then converted into a single ASCII character, offset by 63 so that an all-black sixel, 0 decimal, is encoded as ?. This ensures that the sixels remain within the printable character range of the ASCII character set. Carriage return (CR) is represented by $, and line feeds (LF) with a -; both had to be sent in turn to return the cursor to the start of the line, CRLF.

Sixel also included a rudimentary form of compression, using run length encoding (RLE). This was accomplished with the ! character followed by a decimal number of the times to repeat, and then a single sixel character to be repeated. Since the ! and decimal digits could not be valid sixel data, lying outside the encoded range, the encoding was easy to identify and expand back out in software.

"Sixel mode" was entered by sending the sequence ESC+Pp1;p2;p3;q. The p1 through p3 were optional setup parameters, with p1 defining an aspect ratio (deprecated in favor of p3), p2 how to interpret the color of zeros, and p3 with simple grid size parameters. ESC+P is the standard DEC "Device Control String", or DCS, which was used to turn on or off a number of special features in DEC's equipment. The "q" is the sixel identifier. Sixel data then followed the q. The "Stop Text" sequence ESC+\ returned the device back to normal character mode again.

For printing, sixels are sent to the printer, decoded back into binary, and sent directly to the six pins of the print head. The only complexity involved expanding the RLEs into the internal print buffer. Display on a terminal is somewhat more difficult. On terminals supporting graphics, the ReGIS graphics system was used to directly draw the sixel pattern into the screen's bitmap. This was done at high speed by storing the bitmap patterns as a glyph and then bitting them.

When used for defining custom character sets the format was almost identical, although the escape codes changed. In terms of the data, the only major difference was the replacement of the separate CR/LF with a single /. In the VT300 series for instance, 80-column character glyphs were 15 pixels wide by 12 high, meaning that a character could be defined by sending a total of 30 sixels.

Color was also supported using the # character, followed by a number referring to one of a number of color registers, which varied from device to device. The colors in the registers were defined using either RGB or HSV values in a peculiar DEC format. To create a color image on a printer, a line of sixels was sent several times, each representing a single bitplane from the register-based colors on the terminals (normally 2 or 4 bits). Since the capabilities of the hardware varied widely, a color sixel drawing could only be output to targeted devices. Non-graphics terminals would generally silently ignore sixel escape sequences.


The sample Sixel code that says "HI" displayed in a xterm with VT340 emulation.

The example above enters sixel mode, sets up three color registers, and then uses those registers to draw sixels in those colors. The #0;2;0;0;0 is interpreted as "set color register 0, use RGB mode (2), set R, G and B to 0". This sets color 0 to black, and the following commands set register 1 to yellow and 2 to green.

The data lines following select a color, yellow for the first and third and green for the middle, then draw sixels. The last line shows the RLE in use. These sixels form the shape "HI".

See also[edit]

  • ReGIS, the DEC graphics language


External links[edit]