This is a summary as to how the various image formats in X-Com games work. As UFO/TFTD are palette based games, a common factor is that each image file can be decoded to a set of indexes into those.
(Page contents mostly stolen from Daishiva's site).
This format stores archives of 32x40 sprites for use in the BattleScape or 32x48 sprites in BIGOBS.PCK.
PCK files use RLE encoding to store the images as most of each sprite is (usually) transparent. To decompress, read the first byte and skip down that many rows, then the following algorithm applies: If the byte is 254/xFE, the byte following is the number of transparent pixels. Any other byte is a color index (with the exception of 255/xFF which signals the end of that sprite's data).
PCK files pair with TAB files like bread and butter. It's possible to have one without the other, but the only case where this is done is with the one-image-per-file BIGOBS entries in the UFOGRAPH folder (all other PCK files without an accompanying TAB file aren't actually using the PCK format at all).
The TAB file is a list of file offsets saying where each image begins in the related PCK archive. Some offsets are encoded in 2 bytes while others are encoded in 4. It depends on how many images are in the PCK archive. For TFTD, terrain tab files are 2-byte offsets while all the units are 4-byte; For UFO, every tab file uses 2-byte offsets. (Apocalypse uses TFTD's 4-byte TAB's but a version of PCK images currently not documented here).
When rendering the BattleScape the engine gets the MCD index from the MAP.DAT data, in the MCD data it looks up the TAB index + current animation cycle(0-8), in the TAB data it looks up the offset where to start reading PCK data, it reads PCK data sequentially drawing the pixels on a buffer until it reads the 255/xFF.
SCR & DAT
These ones are easy, every byte is an uncompressed index into the game's palette. Typically SCR files are used for 320x200 background images (and often stored in greyscale so they can be re-colored on the fly). DAT files that contain images use the same format, though the line width tends to vary depending on the specific use to which they are to be put.
Another 320(pixels wide) x 200(pixels high) image format but using compression, primarily used by UFO for background images (eg inventory screens).
Read a 16-bit unsigned integer, call it "a".
- If "a" is 0xFFFF (65535) then you must read another 16-bit integer, and skip that number*2 pixels.
- If "a" is 0xFFFE (65534) then the next 16-bit integer*2 specifies the number of pixels you are going to draw. Read that number of bytes from the file and draw their indexed color.
- If "a" is 0xFFFD (65533) then you are done. This is always the last code in the file.
Rinse and repeat until EOF.
A TFTD only format which essentially replaced SPK files.
To decompress, read a byte and call it "a".
If "a" is 129 or greater, then draw 257-a pixels of the next byte; otherwise, read a+1 bytes from the file and draw those colors sequentially.
Rinse and repeat until EOF.
When encoding each scanline must be represented on it's own and in it's entirety. If a single "a" code directs the decoder to output color values past the end of the current row they'll be discarded (unlike the other formats where it'll automatically jump down to the beginning of the next row and continue to draw).
Screenshots captured using the F12 key are stored in TGA format. Truevision TGA, better known as TARGA format, is a raster graphics file format developed in 1984, enhanced in 1989 (when it was "state of the art"), but still in widespread use over 20 years later.