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 Element | Length (bytes) |
<--Picture File-->\n | 19 |
length 1 | 6 |
picture body 1 | length 1 |
length 2 | 6 |
picture body 2 | length 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:
Type | Value |
Freehand | 0 |
Line | 1 |
Rectangle | 2 |
Oval | 3 |
Polygon | 4 |
Curve | 5 |
Filled Rectangle | 6 |
Filled Oval | 7 |
Filled Polygon | 8 |
Filled Curve | 9 |
Light Spray | 10 |
Heavy Spray | 11 |
Text | 12 |
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 Element | Length (bytes) |
color | 3 |
type 1 | 1 |
segment body 1 | varies |
link 1 | 2 |
type 2 | 1 |
segment body 2 | varies |
link 2 | 2 |
... | ... |
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 Element | Length (bytes) |
no line segments | 2 |
line size | 2 |
color | 3 |
x1 coord | 2 |
y1 coord | 2 |
x2 coord | 2 |
y2 coord | 2 |
... | ... |
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 Element | Length (bytes) |
no points | 2 |
line size | 2 |
color | 3 |
x1 coord | 2 |
y1 coord | 2 |
x2 coord | 2 |
y2 coord | 2 |
... | ... |
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 Element | Length (bytes) |
line size | 2 |
color | 3 |
x1 coord | 2 |
y1 coord | 2 |
x2 coord | 2 |
y2 coord | 2 |
x3 coord | 2 |
y3 coord | 2 |
x4 coord | 2 |
y4 coord | 2 |
Light and Heavy Spray Segments
These segments consist of the color followed by the position of the center of
the spray.
Picture Element | Length (bytes) |
color | 3 |
x coord | 2 |
y coord | 2 |
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 Element | Length (bytes) |
no characters | 2 |
font | 2 |
color | 3 |
x coord | 2 |
y coord | 2 |
character 1 | 1 |
character 2 | 1 |
... | ... |
The lower byte of font contains the font point size and the upper byte is coded
as follows:
Italic | 1 |
Bold | 2 |
Helvetica | 4 |
Times Roman | 8 |
Courier | 16 |
Dialog | 32 |
Dingbats | 64 |
Line Segment
This segment consists of the line size and color followed by the line's end point
positions.
Picture Element | Length (bytes) |
line size | 2 |
color | 3 |
x1 coord | 2 |
y1 coord | 2 |
x2 coord | 2 |
y2 coord | 2 |
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 Element | Length (bytes) |
line size | 2 |
color | 3 |
x coord | 2 |
y coord | 2 |
width | 2 |
height | 2 |