GEM pages
Home -> GEM -> GEM file formats -> IMG

Format of GEM bitmap (.IMG)

[31-Mar-2005] And a big hello to Microsoft Support, who have sent at least one person to this page with a problem that I'm certain is not in any way related to the GEM/Ventura bitmap file format. I think that's positively cheeky. You're paid to support Windows - I'm not. Why should I do your work for you?]


The GEM bitmap is the save file format used by GEM Paint and Ventura Publisher. Some programs seem to be aware only of the Ventura version and crash on GEM Paint files, or render Paint images as greyscale.

GEM bitmaps are saved with a .IMG extension. However, so are many other file formats, so don't assume that any file ending .IMG is one of these; it might not be a graphics file at all.

All word values are 16-bit, signed and big-endian. In this listing, "DW" (define word) is used to indicate such a word.

File header

    DW  version 
    DW  header_size
    DW  planes
    DW  pattern_size
    DW  pixel_width 
    DW  pixel_height
    DW  image_width
    DW  image_height
    (maybe more words)

These fields are:

is (as far as I can tell) always 1.
is the number of words in the file header. This is 8 for GEM Paint files and 9 for Ventura files.
is 1 for monochrome files and 4 for 16-colour files. Paint Shop Pro can also save an 8-plane greyscale file; presumably this file format is used by Ventura.
is the length in bytes of a pattern (see below), 1-8. GEM Paint uses 2 bytes.
are the size of a pixel in tenths of a millimetre. These give the aspect ratio of the image.
image_width, image_height
are the actual dimensions of the image.

Image data

The image is formed of image_height * planes rows of data. For a multi-plane image, the first planes rows are the colours for the first screen line, the next planes rows are for the second, and so on. A normal four-plane image stores the planes in order R,G,B,I.

A row is formed of one or more records, of three types. Records do not span multiple rows;


    DB  rlebyte

This record is a single byte. Bits 6-0 hold the number of repetitions (1-127). If bit 7 is 0 then the byte to be repeated is 0; else it is 0xFF.

Literal string

    DB  80h
    DB  count
    DB  byte,byte,...

This record contains a number of bytes of literal data. The record size is 2 + count


    DB  00h
    DB  number of repetitions
    DB  byte,byte,...

The pattern is a repeated sequence of bytes. The number of bytes in a pattern is given in the header; hence the record length is 2 + pattern_size.

Repeated rows

    DB  00h, 00h, 0FFh
    DB  number of repetitions
    (records for a planes rows)

If a set of planes rows (ie, one line of pixels) is repeated several times, then the 4-byte sequence above is used to reduce it to a single instance.