Understanding the ZSoft PCX File Format Structure
The Personal Computer eXchange (PCX) format was one of the earliest widely accepted graphics file formats on MS-DOS and Windows platforms, popularized by the PC Paintbrush software. Operating as an uncompressed or simple run-length compressed bitmap file, PCX is highly lightweight. A standard PCX file consists of a fixed-size 128-byte header followed by the image data:
- Manufacturer: Always set to
10(represented as0x0Ain hex) to indicate ZSoft Corporation. - Version: Version number indicating color configuration capabilities. Version
5supports 24-bit true color images. - Encoding: Set to
1to indicate ZSoft Run-Length Encoding (RLE) compression. - Bits Per Pixel per Plane: Always
8bits for 24-bit true-color images. - Color Planes: Set to
3planes (Red, Green, and Blue) to store 24-bit RGB datasets. - Bytes Per Scanline: The buffer length per plane scanline. In accordance with PCX requirements, this value must always be an **even number** to maintain byte alignment. If the image width is odd, a dummy pad byte is added.
- Pixel Data: Raw pixel planes packed scanline-by-scanline and compressed using ZSoft RLE.
How ZSoft RLE Compression Works
ZSoft PCX compression is a simple byte-oriented RLE (Run-Length Encoding) scheme:
- It analyzes sequential bytes inside each scanline plane.
- If it finds a run of identical bytes (up to 63 bytes), it packs them: the first byte acts as a count byte (with the top two bits set to
11, i.e.,0xC0 | runLength), and the second byte holds the actual color value. - If a byte is unique (run length of 1) and its value is less than 192 (
0xC0), it is written directly in 1 byte. If its value is 192 or higher, it must be written using the 2-byte RLE code even with a count of 1. - RLE sequences never cross scanline boundaries, preventing buffer overflow errors in legacy decoders.
Solid Background Blending: Handling Transparency
Modern web formats like PNG and WEBP support alpha transparency. Since PCX is an older, opaque format without an alpha channel, transparent pixels must be flattened. Our tool blends transparent layers with your selected backdrop color picker (defaulting to white) before RLE encoding occurs, preserving visual clarity.
Actionable PCX Integration & Best Practices Checklist
1. Keep Aspect Ratio Locked for Resizing
When resizing your target images for legacy MS-DOS games or retro setups, keep aspect ratios locked to prevent stretching.
2. Handle Transparency Proactively
Since PCX is opaque, check your transparent PNG assets. Adjust the background color picker to make sure text remains legible.
3. Verify Even Scanline Alignment
Our compiler automatically adds padding bytes for odd-width layouts, guaranteeing full compliance with retro decoders.
4. Secure Client-Side Execution
Our converter processes files locally in the browser sandbox. No images are sent to any remote database.
PCX Specifications
image/x-pcx
24-bit True Color (RGB, 3 planes at 8 bits per pixel per plane).
ZSoft Run-Length Encoding (RLE) with a maximum run count of 63 bytes.
Fixed 128 bytes with even-aligned bytes per scanline setting.
Why PCX?
PCX is a classic format used extensively in classic DOS games, hardware emulator pipelines, and legacy desktop publishing files. Its simplicity and low computing requirement make it highly useful for retro hobbyists.