Lotus PIC format

Lotus PIC is a simple vector graphics format originally designed for use by a support application of Lotus 1-2-3. My interest in it is as an export format for graphs generated by the Psion Sheet application.

General Information

The format is very simple, with a fixed-length header followed by any number of vector graphics commands. There are no internal offset or length fields, so the entire format can be generated or read serially. The format is big-endian. In the description below, word means a 16-bit value.

Header

The header consists of 17 bytes with constant values. The last four bytes consist of two words defining the overall scale of the picture, which always fits into a rectangle 3200 units wide by 2311 tall.

The first 17 bytes:

01 00 00 00 01 00 08 00 44 00 00 00 00 0C 7F 09 06

0C7F = 3199 decimal
0906 = 2310 decimal

Vector Data

The rest of the file contains of a set of commands, each of which consists of a command byte, possibly followed by parameter bytes. The last command in the file will be "End of Data".

Filled Polygon

Command: 30
Parameters: One byte containing the number of vertices less one, then the set of vertices as (x,y) word pairs. For example,

30 02 00 01 00 02 00 32 00 64 01 90 00 50

defines a triangle with vertices at (1,2), (50,100) and (400,80).

Move
Moves the current position to the given coordinates. Doesn't draw anything.

Command: A0
Parameters: (X,Y) as words.

Draw Line
Draws a line from the current position to the given coordinates and updates the current position.

Command: A2
Parameters: (X,Y) as words.

Font Change
Changes between two possible types of font. Not supported by LPIC2PS.

Command: A7
Parameters: One byte which should be zero or one.

Draw String
Draws a string of characters at the current drawing position.

Command: A8
Parameters: One byte containing position information, followed by a NUL-terminated string of characters. The position byte consists of a direction most-significant nybble and an alignment least-significant nybble.

Text in direction 0 goes right, 1 goes up, 2 goes left and 3 goes down
Font Size
Sets the size of the character cell.

Command: AC
Parameters: Two words, giving the size of the character cell in X and Y directions.

End of Data
The last byte of the file.

Command: 60
Parameters: None.

Set Drawing Colour

Command: B0-BF
The low nybble of the command byte contains the new colour. Not supported by LPIC2PS.

Filled Polygon with Outline

Command: D0
Parameters: as for Filled Polygon, above. I don't know which colour should be used for the filling and which for the outline. LPIC2PS doesn't support colour anyway, so this hasn't been keeping me awake at nights.