Graphic file formats

From Ninerpedia
Jump to navigation Jump to search

TI ARTIST format

The TI ARTIST file format actually involves two files, a pattern and a color file. Both are stored on the file system as a file ending with "_P" and "_C", respectively.

This is just a dump of the pattern table and the color table as used in the bitmap mode of the Video Display Processor. Accordingly, each file is 6144 bytes long.

MyArt format

Images for MyArt (Geneve painting program) are saved in this format:

0 1 2 3 4 5 6 7
0x00 Background Version Color 0 Color 1 Color 2
0x08 Color 3 Color 4 Color 5 Color 6
0x10 Color 7 Color 8 Color 9 Color 10
0x18 Color 11 Color 12 Color 13 Color 14
0x20 Color 15 RLE RLE RLE
... ... ... ... ...

or in that format:

0 1 2 3 4 5 6 7
0x00 Background Version RLE RLE RLE
0x08 RLE RLE RLE RLE
... RLE RLE RLE RLE


Version / Flag byte

The flag byte in position 1 varies between different programs (MyArt, YAPP etc.).

Barry Boone's MyArt loader considers 0xFF as indication for the G6 mode.

According to the documentation of the XHi program (A. Hulpke), the Austrian MYLOAD tool uses bits 4-6 for the mode bits M5, M4, M3 of video register 0, i.e. for 512 columns (G6) it is expected to be xxxx1010, and for 256 columns (G7) it is xxxx1110.

For MyArt, values for the flag byte are 0x9E and 0xFA (G6 or G7), possibly as a version indicator. MyArt does not use a header for G7 files (picture data begin right after the version byte).

Color palette definition

In MyArt, the 512 column mode (G6) uses an indexed color mode, so the file starts with a sequence of palette color definitions before the line segments.

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 Red 0 Blue 0 0 0 0 0 Green

Although only 3 bits are available for color definition, MyArt sometimes creates seemingly meaningless bits at positions 8-12.

RLE entries

RLE (Run-length encoding) entries look like this for G6 mode:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Color 0 0 Length

where length can be any value from 0x001 - 0x200 (1-512).

For G7 mode we have this format:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Color Length

where a length of 0 means 256.

Each line element is a sequence of pixels of the given color and the given length, extending to the right. The next line element is painted one position to the right of the end of the previous one. Each screen line must have a list of line elements that add up to its length exactly, so they must not reach beyond the right border of the screen. This allows the painting program to know when a line is complete and the painting continues in the next screen row.

YAPP format

YAPP is a painting program written by Alexander Hulpke, compatible to MyArt but adding some more features, including double vertical resolution by interlacing.

The YAPP format is similar to the MyArt format. The flag byte has the following definition:

0 1 2 3 4 5 6 7
/Inter- laced OM 1 1 1 G7 1 0

With /Interlaced set to 0, the picture uses 424 lines in interlace mode. OM should be set to 1. According to the YAPP documentation, when reset, the picture is stored in the wrong mode in order to save disk space. The bits 4-7 are defined this way to be compatible with the "Austrian" format.

Interlaced pictures are stored in line order of the screen, not separated as two frames (like in memory).

FRACTALS! format

This is a special file format as used in my own FRACTALS! program. It is derived from the MyArt format but has some special adaptations for use with fractal pictures:

  • Contains metadata like viewport parameters and plain text description of the image.
  • Supports two modes of pixel storage: Run-length encoding (like MyArt) and direct encoding (for small run lengths).

The file format is DIS/FIX 255, and the flag byte is always 0x43 ("C") or 0x4d ("M"). C stands for cyclic coloring scheme, while M indicates the semi-monotonous coloring scheme. In the cyclic mode, iterations are indicated by a color code which is the remainder of dividing the iteration number by 16. In the semi-monotonous mode, colors of odd iterations always stay the same or increase by one, while the same is true for all even iterations, so you get an alternating sequence like 1 2 1 2 1 2 1 2 3 2 3 2 3 2 3 4 3 4 ... which uses the lowest color codes for the smallest iteration counts, and the highest codes for the highest iterations in the picture which do not reach the maximum iteration (which would be the black Mandelbrot set).

First record

0 1 2 3 4 5 6 7
0x00 Background "C" or "M" Color 0 Color 1 Color 2
0x08 Color 3 Color 4 Color 5 Color 6
0x10 Color 7 Color 8 Color 9 Color 10
0x18 Color 11 Color 12 Color 13 Color 14
0x20 Color 15 XMIN
0x28 XMIN (low word) XMAX
0x30 XMAX (low word) YMIN
0x38 YMIN (low word) YMAX
0x40 YMAX (low word) Iterations 0 0 0 0
0x48 Comments
... Comments
0xf8 Comments

Later records

Each record contains a sequence of specifications of the following two formats:

  1. Run-length encoding: Defines the pixel color (first 4 bits) and the number of repetitions (remaining 12 bits).
  2. Direct encoding: Defines one pixel per half-byte.

The number of screen rows is 212, the number of columns is 512. From the format, the number of repetitions could be 4095 at most, but this is never used since all length encodings must finish at the end of the screen line. Accordingly, we will never find repetitions higher than 0x200.

Format 1

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Color 0 0 0 Number of pixels of this color


Format 2

First word:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Color 1 0 0 Number of following pixels for this specification

Following bytes:

0 1 2 3 4 5 6 7
Color Color

When all pixels have been used, either a format 1 word or a new format 2 word will follow. This file formats greatly improves the unwanted overhead for pictures with pixel noise or alternating colors. For instance, if there were a sequence "123456789abcd" of pixel colors, the RLE format (format 1) requires 13 words (one word for each pixel), while format 2 merely requires 4 words (180c 2345 6789 abcd). Note that the length specification does not count the pixel defined in the first word.

Pictures of fractals usually contain areas with a lot of color changes, so this format allows to significantly lower the RLE overhead without information loss.