QuantumPaint file format

From Atari Wiki
Jump to navigation Jump to search
QuantumPaint    *.PBX (low and medium resolution)

3 bytes         0
1 byte          mode, 0x00 =  128 color low resolution pciture, 
                      0x01 =   32 color medium resolution picture,
                      0x80 =  512 color picture low resolution picture
                      0x81 = 4096 color picture low resolution picture
1 word          0x8001 = compressed
                Quantumpaint v2.00 sets it to 0x8000 for uncompressed files
                Quantumpaint v1.00 seems to use 0x0000 for lowras and 0x0333
                for medium res bytes. The PBX viewer only tests for 0x8001.
122 bytes       ??
                total 128 header bytes
?? bytes        palette data;
                for uncompressed normal pictures 8 pallete datasets follow:
                    16 words: 16 palettes
                     1 word: number of the first line this pallet is used
                     1 word: 0 the palette is not active, else this pallete is active
                     1 word: first color of color cycle
                     1 word: last color of color cycle
                     1 word: cycle speed, number of vbl's between steps, 0 = fastest
                     1 word: 0: no cycling, 1 cycle right, 0xffff cycle left
                     2 word: ?? should be zero
                    __
                    48 bytes per palette
                    The first palette should always be active and start on line 0
                   ___
                   384 bytes palette data for low (128 color) and medium (32 color) pictures
                for uncompressed 512 color pictures 6400 words (32 colors per scanline)
                for uncompressed 4096 color pictures 12800 words (32 colors per scanline,
                2 palette sets for alternating screens, two 6400 word blocks)
?? bytes        screen data, for uncompressed pictures this is 32000 bytes for all modes
--------
> 128 bytes total

Compression scheme
Palette and screen data are compressed into one block using packbits compression.
The expanded screen data is not simply screen memory bitmap data; instead, the 
data is divided into four sets of vertical columns.  (This results in
better compression.)  A column consists of one specific word taken
from each scan line, going from top to bottom.  For example, column 1 
consists of word 1 on scanline 1 followed by word 1 on scanline 2, etc., 
followed by word 1 on scanline 200.
   The columns appear in the following order:

   1st set contains columns 1, 5,  9, 13, ..., 69, 73, 77 in order
   2nd set contains columns 2, 6, 10, 14, ..., 70, 74, 78 in order
   3rd set contains columns 3, 7, 11, 15, ..., 71, 75, 79 in order
   4th set contains columns 4, 8, 12, 16, ..., 72, 76, 80 in order
This colmn ordering is just the same as in the Tiny format.
for medium res it is the same only with two stes for the two medium res bitplanes.

/*
 *  Given an x-coordinate and a color index, returns the corresponding
 *  QuantumPaint palette index.
 *
 *  by Hans Wessels; placed in the public domain January, 2008.
 */
int find_pbx_index(int x, int c)
{
	int x1 = 10 * c;
	if (1 & c)
	{	/* If c is odd */
		x1 = x1 - 5;
	}
	else
	{	/* If c is even */
		x1 = x1 + 1;
	}
	if(c>7)
	{
	  x1+=12;
	}
	if(x>=(x1+75))
	{
		c = c + 16;
	}
	return c;
}

Back to ST Picture Formats