Picture File Format

A picture file consists of a header followed by one or more pictures. The header consists of the string "<--Picture File-->\n". This header is used to mark the file as a picture file and only existing files that are so marked are written to by the Perl script WritePicture.

Pictures consist of a 6 byte length followed by a picture body. The length is the number of bytes contained in this picture body.

Picture ElementLength (bytes)
<--Picture File-->\n19
length 16
picture body 1length 1
length 26
picture body 2length 2
......

Picture Body Format

A picture body consists of a color followed by one or more picture segments. The color defines the background color of the picture and consists of 3 bytes which are the color's red, green and blue components. A picture segment consists of a one byte type followed by a segment body followed by a two byte link. The possible types and there values are:

TypeValue
Freehand0
Line1
Rectangle2
Oval3
Polygon4
Curve5
Filled Rectangle6
Filled Oval7
Filled Polygon8
Filled Curve9
Light Spray10
Heavy Spray11
Text12

The two byte link is a byte pointer pointing to the start of the picture segment. This link is used to remove segments when the 'Undo' button is clicked.

Picture ElementLength (bytes)
color3
type 11
segment body 1varies
link 12
type 21
segment body 2varies
link 22
......

Freehand Segment

This segment consists of the number of line segments, line size and color followed by the positions of the end points of the line segments. The positions consist of x and y coordinates.

Picture ElementLength (bytes)
no line segments2
line size2
color3
x1 coord2
y1 coord2
x2 coord2
y2 coord2
......

Polygon and Filled Polygon Segments

These segments consist of the number of points, line size and color followed by the positions of the polygon's defining points.

Picture ElementLength (bytes)
no points2
line size2
color3
x1 coord2
y1 coord2
x2 coord2
y2 coord2
......

Curve and Filled Curve Segments

These segments consist of the line size and color followed by the position of the curve's start point followed by the positions of the curve's 2 control points followed by the position of the curve's end point.

Picture ElementLength (bytes)
line size2
color3
x1 coord2
y1 coord2
x2 coord2
y2 coord2
x3 coord2
y3 coord2
x4 coord2
y4 coord2

Light and Heavy Spray Segments

These segments consist of the color followed by the position of the center of the spray.

Picture ElementLength (bytes)
color3
x coord2
y coord2

Text Segment

This segment consists of the number of characters, font and color followed by the position of the bottom left corner of the text followed by the characters in the text.

Picture ElementLength (bytes)
no characters2
font2
color3
x coord2
y coord2
character 11
character 21
......

The lower byte of font contains the font point size and the upper byte is coded as follows:

Italic1
Bold2
Helvetica4
Times Roman8
Courier16
Dialog32
Dingbats64

Line Segment

This segment consists of the line size and color followed by the line's end point positions.

Picture ElementLength (bytes)
line size2
color3
x1 coord2
y1 coord2
x2 coord2
y2 coord2

Rectangle, Oval, Filled Rectangle and Filled Oval Segments

These segments consist of the line size, color, x coord, y coord, width and height. The x and y coordinates specify the position of the top left corner of the defining rectangle while the width and height specify the rectangle's dimensions.

Picture ElementLength (bytes)
line size2
color3
x coord2
y coord2
width2
height2