PIC Format

From ModdingWiki
Jump to: navigation, search
PIC Format
There is no example of an image in this format — upload one!
Format typeImage
HardwareCGA, EGA
Colour depth2-bit (CGA), 4-bit (EGA)
Minimum size (pixels)320×200
Maximum size (pixels)320×200
Plane count2-4
Transparent pixels?No
Hitmap pixels?No

The various versions of the PIC format are used by many games to store image data. It is named after the file extension of the screenshots from Commander Keen 1-3, which are saved in this format.

In some cases, the PIC files are compressed (with Keen 1-3 RLE compression or normal RLE compression). If this is the case, they need to be decompressed before they can be read.

PIC format version 0

PIC files in version 0 contain raw image data (CGA, EGA and in theory even VGA) and have no header. The images seem to be always sized 320x200 pixels.

For a 320x200 image, the size of the PIC file is:

  • CGA: 16384 Bytes (0x4000)
  • EGA: 32768 Bytes (0x8000)

Obviously, the PIC files contain more than just the raw image data. This is because the files contain multiple blocks of 192 bytes of padding between planes, as they are intended to be loaded directly into video memory. These blocks appear after every 8000 bytes of image data and should be ignored during normal processing. This means an EGA image will have this structure:

Location Size Description
0x0000 8000 Blue Plane data
0x1F40 192 Padding Block
0x2000 8000 Green Plane data
0x3F40 192 Padding Block
0x4000 8000 Red Plane data
0x5F40 192 Padding Block
0x6000 8000 Intensity Plane data
0x7F40 192 Padding Block

So, to read the raw EGA data from a PIC file, you can set the plane size to 0x2000 and skip the last 192 bytes of each EGA plane.

The structure of a PIC file with CGA image data is the same as above, only with two planes instead of four (Interlaced CGA). The first plane is pixel data for even lines, and the second plane is pixel data for odd lines.

This is a bit tricky because the even-numbered pixel lines (0, 2, 4, ..., 198) are read first and the odd-numbered lines (1, 3, 5, ..., 199) follow after the padding block. This is different from the way raw CGA data is stored in other file formats such as the xGAPics Format, where all pixel lines can be read in order.

PIC format version 1

PIC files in version 1 come with the following header of 4 Bytes:

Offset Type Description
0 UINT16LE width image width in bytes-per-line
2 UINT16LE height image height in pixels

The rest of the file is just Graphic-planar EGA data (plane-order: B-G-R-I), but without the padding blocks that version 0 had. This format has so far only been seen storing EGA data.

This version of the PIC format is used in Shadow Knights.

PIC format version 2

Version 2 of the PIC format is pretty much identical to version 1. The only difference is an additional name tag in the header:

Offset Type Description
0 char name_tag[4] always "PIC\0"
4 UINT16LE width image width in bytes-per-line
6 UINT16LE height image height in pixels

This version of the PIC format is used in Rescue Rover.


This file format (at least the CGA part) was reverse engineered by K1n9_Duk3. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)