Public Painter file format

From Atari Wiki
Revision as of 05:31, 7 January 2017 by Lp (talk | contribs) (New page)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
Public Painter    *.CMP

Always monochrome.

1 byte    flag [used during decompression]
1 byte    size [0 = A5/640x400, 200 = A4/640x800]
-------
2 bytes   total for header

?         image data:

The image data is always RLE compressed.

Depending on the size field the uncompressed image will be 32000 or 64000 bytes.

Decompression code -> parameters: 
  data = source address (compressed image data)
  bmap = destination address (uncompressed monochrome image data)
  flag = first item from file header
  cds  = compressed data size (file size minus sizeof(header))
  
uint32 decode_cmp(uint8 *data, uint8 *bmap, uint8 flg, uint32 cds) {
    register uint8  byt, cmd;
    register uint16 i, cnt;
    register uint32 dst=0, src=0;

    do {
        cmd = data[src++];
        if (cmd == flg) {                   /* repeat? */
            cnt = 1 + data[src++];
            byt = data[src++];
            for (i=0; i<cnt; i++) {
                bmap[dst++] = byt;
            }
        } else {                            /* literal ? */
            bmap[dst++] = cmd;
        }
    } while (src<cds);
    return dst;
}

Back to ST Picture Formats