STP Format

From ModdingWiki
(Redirected from STP Image)
Jump to: navigation, search
STP Format
STP Format.png
Format typeImage
HardwareVGA
Colour depth8-bit
Minimum size (pixels)0×0
Maximum size (pixels)65535×65535
PaletteVaries
Plane count1
Transparent pixels?Yes
Hitmap pixels?No
Games

STP is a run-length encoded VGA image format. Its name is an abbreviation of the word "stamp", which describes its intended use in drawing over an existing background with transparency. STP images are generally smaller than the full screen resolution, and it is the responsibility of the game engine to determine the on-screen coordinates at which an STP is to be drawn.

Related STP images are sometimes packed together in a simple archive that uses the ROL Format.

Header

The file starts with four 16-bit words that describe the image size and any adjustments to the drawing location on screen.

Data type Description
UINT16LE width Width of the image in pixels
UINT16LE height Height of the image in pixels
UINT16LE negativeXOffset Negative horizontal offset, in pixels, of the drawing location
UINT16LE negativeYOffset Negative vertical offset, in pixels, of the drawing location

Example of negative X,Y offsets: if the game engine is preparing to draw a stamp at 100,100 and the .STP data contains 02 00 02 00 at offsets 04 through 07, then the stamp will actually be drawn with the upper left corner at 98,98.

The STP raster image data starts at offset 08. Each chunk of data in the file starts with a runlength byte, which describes that chunk as being one of three types:

  • Pointer advance / background: Marked by bit 7 being set (bitmask 80h). In the game engine, this simply advances the pointer in the output buffer by the number of bytes specified in the lower seven bits of this RLE byte (bitmask 7Fh). For example, B8h will advance the output pointer by 38h bytes. The effect of this is that the existing content of the output buffer will persist, making this run transparent in the STP.
  • Repeat byte from input: Marked by bit 7 being clear and bit 6 being set. This loads the next byte from the input buffer, and repeats it to the output buffer the number of times specified in the lower six bits of this RLE byte (bitmask & 3Fh).
  • Direct byte sequence copy from input: Marked by both bits 7 and 6 being clear. This copies the next n bytes, in sequence, from the input, where n is the value of this RLE byte.