Difference between revisions of "Graphic file formats"

From Ninerpedia
Jump to navigation Jump to search
Line 16: Line 16:
| 0x00
| 0x00
| Background
| Background
| Flags
| Version
| colspan="2" | Color 0
| colspan="2" | Color 0
| colspan="2" | Color 1
| colspan="2" | Color 1
Line 62: Line 62:
| 0x00
| 0x00
| Background
| Background
| Flags
| Version
| colspan="2" | RLE
| colspan="2" | RLE
| colspan="2" | RLE
| colspan="2" | RLE
Line 82: Line 82:




=== Flag byte ===
=== Version / Flag byte ===


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

Revision as of 22:10, 7 March 2013

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 at the start).

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

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").

First record

0 1 2 3 4 5 6 7
0x00 Background "C" 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 pixels for this specification

Following words:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
Color Color 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 (180d 2345 6789 abcd).

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.