Pfaff PCD2 File Format

This is a description of the internal structure of files used by Pfaff's Creative Designer for Windows, version 2, hereafter referred to as PCD2. The DumpPCD program can be used to display an ASCII representation of a PCD2 file. Glossary of data types.

Header

The file begins with a small header, shown below with C syntax:
struct Header
{
    char two;           // magic number, must be '2'
    BYTE mode;          // file type (ie. PCD, PCQ, PCS small and large)
    USHORT cColorMap;   // number of entries in color map
};
The first character in the file is the character 2 (ASCII code 32 hex, 50 decimal). This identifies the file as being in PCD2 format. A byte follows with one of four values, 0 for PCD, 1 for PCQ (MAXI), 2 for PCS with small hoop, and 3 for PCS with large hoop. Next is an unsigned 16-bit count of the number of entries in an optional color map. For PCD and PCQ files, this value is always 0, meaning no color map is present. Standard PCS files use the value 16, and the header will immediately be followed by 16 color map entries.

Color Map

Each entry in the color map contains 4 bytes of color information in the following format:
struct RGB2
{
    BYTE bBlue;
    BYTE bGreen;
    BYTE bRed;
    BYTE fcOptions; // always 0
};
Following the optional color map is an unsigned short with the number of stitch records in the file. (This does not include color change records, which are interleaved with the stitch records, so one must count stitches as one parses the file. One cannot simply index by stitch number.)

Stitch and Color-Change Records

Stitch and color change records come next. (PCD and PCQ files will contain no color change records.) Both records are 9 bytes long, and they look like this:
struct PCD2_record
{
    union
    {
        POINTL stitch;  // scaled by 256
        BYTE color;     // high 7 bytes should be zero
    } body;
    BYTE tag;   // record type (0,2 = stitch, 3 = color)
};
A stitch is identified by tags 0 and 2. (I haven't yet figured out what distinction the program gives to these two tags, except that I've only seen tag 2 stitches following a fill operation.) A tag value of 3 means that the record is a color change record. The coordinates in the stitch record are scaled by 256. This means that the units of the record are 1/256 the size of a unit in the program. To convert to program units, divide by 256. The color value found in a color change record is the index into the earlier-encountered color map. All other bytes in the color record should be 0.

BMP File Name

After all stitch records have been encountered, the BMP file name appears. This occupies 13 bytes, allowing a standard 8.3 DOS filename, and is null-terminated.

Remarks

File remarks appear after the BMP file name. These are null-terminated. Even if no remarks are present, the null will be there. This will be the last character in the file.

Glossary of Data Types

BYTE
8-bit unsigned value
USHORT
16-bit unsigned value, least-significant byte first
LONG
32-bit signed (2's-complement) value, least-significant byte first
POINTL
coordinate
struct POINTL
{
   LONG  x;
   LONG  y;
};

Back to the sewing page
Last updated June 8, 1999 by webmaster@sewingwitch.com

My pages have been visited many times.