Binary specs

In this section, we'll learn about the binary specs of .px files so that anyone can decode the file for various purposes.

Disclaimer: There are a lot of backward compatibility details in the files, but for the sake of simplicity, they will be ignored and only the latest specs are available here.

How to decode

Models without header

These are pretty simple, their sizes are pre-determined, so just consume data and decode the values one by one to fill the properties of the models

Models with header

All headers contain a field to specify the length of the model. Use that field to determine where the model ends.

We'll see that there are properties within the models that have default values. If we reach the end of the data for the model, but there are still fields that need values, simply use the default value in this case.

Data types

These are some simple data types. .px files use little-endian byte order.

Primitive types

These are notated similarly to Swift data types

  • UInt - A n-bit unsigned integer

    • UInt8 is an 8-bit unsigned integer

  • Int - A n-bit signed integer

    • Int16 is a 16-bit signed integer

  • Float - A n-bit float

    • Float32 is a 32-bit float

  • Bool - A boolean value, 1 byte

  • OptionSet<UInt> - A set of true (1) - false (0) flags using each bit of the UInt type

    • OptionSet<UInt8> has 8 flags. So0b10010001 has 1 << 0, 1 << 4, and 1 << 7 flag set

  • DumbString - UTF8 data of a string

  • String - A string

    • The first 2 bytes are a UInt16 to specify the length of the String

    • The remaining is the UTF8 data of the string

    • Don't ask me why there is a DumpString in the first place

  • [Type] - An array of Type

    • The first 8 bytes are a UInt64 to specify the length of the Array

    • The rest are the elements

  • Type[n] - n consecutive value of Type

    • UInt8[3] - 3 consecutive UInt8

Composite types

Coordinate

Size

Rect

ARGBColor

RGB channels are alpha pre-multiplied

BlendMode

Corners

Models

Most models in this section have a header. Pixquare uses ID for everything.

All sizes specified in the headers are in bytes and the size doesn't include the header

CustomData

Store some custom data set by the users

Header (16 bytes)

Content

FrameContent

The color data of a cel.

Header (32 bytes)

Content

TilemapFrameContent

The alignment of a tilemap cel.

Header (32 bytes)

Content

Frame

A frame of the artwork.

Header (32 bytes)

Content

SymmetryLline

Header (16 bytes)

Content

Tag

Header (16 bytes)

Content

Tileset

Header (32 bytes)

Content

Fx

Header (16 bytes)

Content

Entry

Represents an entry in the artwork (layer, group, etc.), but doesn't have any actual data of the entry.

Header (16 bytes)

Content

Layer

A layer with all data.

Header (32 bytes)

Content

Group

A group with all data.

Header (32 bytes)

Content

ReferenceLayer

A reference layer with all data

Header (32 bytes)

Content

TilemapLayer

A tilemap layer with all data

Header (32 bytes)

Content

Stats

Contains data like time spent on this file, stroke count, etc.

Header (16 bytes)

Content

CanvasGrid

GuideLine

Header (14 bytes)

Content

Post-processor

Header (16 bytes)

Content

PaletteOrganization

Header (16 bytes)

Content

Artwork

This is the data of .px files.

Header (64 bytes)

Content

Last updated

Was this helpful?