An open source PCX image decoder.
Download dr_pcx.h
dr_pcx is an open source library for decoding PCX image files. It's written in C in a single file with no dependencies except for the C standard library, and is released into the public domain.
Features
  • Public domain.
  • Single file.
  • No dependencies except for the C standard library.
  • Supports all major data formats:
    • 1-bit / 1-plane
    • 1-bit / 4-plane
    • 2-bit / 1-plane (CGA)
    • 4-bit / 1-plane (untested)
    • 8-bit / 1-plane (palette and grayscale are both supported)
    • 8-bit / 3-plane (24-bit truecolor)
    • 8-bit / 4-plane (24-bit truecolor + 8-bit alpha)
  • A consistent API with stb_image.
Limitations and Future Plans
  • A branch exists for 2-bit/4-plane and 4-bit/1-plane images, however they're untested.
  • Only limited testing has been done due to difficulty in finding test files.
Examples
Example 1: Decoding from a file.
#define DR_PCX_IMPLEMENTATION
#include "dr_pcx.h"

int main()
{
    int width;
    int height;
    int components;
    uint8_t* pImageData = drpcx_load_file("my_image.pcx", false, &width, &height, &components);
    if (pImageData == NULL) {
        return -1;
    }

    // At this point pImageData contains the raw decoded image data as tightly
    // packed RGB or RGBA, depending on on the value of "components".

    drpcx_free(pImageData);
    return 0;
}
Developed by David Reid - mackron@gmail.com