GEM Bit Image file format

From Atari Wiki
Jump to navigation Jump to search
GEM Bit Image   *.IMG
1 word          version number of image file [1]
1 word          length of header in words [usually 8]
1 word          number of color planes [1 for monochrome]
1 word          pattern length in bytes [1-8, usually 2 for screen images]
1 word          pixel width in microns (1/1000 mm, 25400 microns per inch)
1 word          pixel height in microns
1 word          line width in pixels
1 word          number of lines
? words         header length defined in 2nd word of header
? bytes         data
NOTES:  If the image is a color image (planes > 1), the planes are stored
separately starting with plane 0.  There is, however, no standard way of
storing the color palette.  Some programs may save the palette in separate
files, some may extend the header.  For this reason, you should never
assume the header is 8 words long, always get the header length from the
2nd word of the header.  Also, the line width in the 7th word is the number
of pixels in a line.  Since the data is encoded in byte-wide packets, the
actual unpacked line width is always a multiple of 8, and may be 1-7 pixels
longer than the length specified in the header.

For each byte x in the data section,
        x = 0           Pattern/scanline run.
                        Read the next byte, n (unsigned).
                        If n > 0 then:
                                Read a number of bytes equal to the "pattern
                                length" word in the header.  Repeat this
                                pattern n times.
                        If n = 0 then:
                                Scanline run.  Data for the next scanline
                                is to be used multiple times.  Read the
                                following record:
                                1 byte          flag byte [$FF]
                                1 byte          number of times to use
                                                next scanline data
                                The data for the next scanline follows,
                                compressed normally.
        x = 80 (hex)    Uncompressed bit string.  The next byte
                        determines the number of bytes to use
                        literally.  The literal data bytes follow.
        otherwise       Solid run.  The value of x determines
                        what to draw.  The high bit specifies whether
                        the pixels are set or cleared.  A 1 indicates
                        a byte-run using $FF, a 0 indicates a byte-run
                        using $00.  The low 7 bits, taken as an unsigned
                        quantity, specify the length of the run in bytes.

Back to ST Picture Formats