XCF File Format
by Amit Dor
- "gimp xcf file" guint8* (14 bytes)
"gimp xcf v100"
- image width guint32 (4 bytes)
- image height guint32 (4 bytes)
- image type enum (RGB/GRAY/INDEXED) (4 bytes)
image tag guint32, used as bitmap
(4 bytes):
bits 8-15 - alpha (ALPHA_NONE/ALPHA_NO/ALPHA_YES)
bits 16-23 - format (FORMAT_NONE/FORMAT_RGB/FORMAT_GRAY/FORMAT_INDEXED)
bits 24-31 - precision (PRECISION_NONE/PRECISION_U8/PRECISION_U16/PRECISION_FLOAT/PRECISION_FLOAT16)
- properties list: contains 0 or more sets of the following
(1-3):
- PropType enum (4 bytes)
- size guint32 (4 bytes)
- data (optional, depending on PropType)
- PROP_END + size (8 bytes)
- layer offsets list guint32 (4 bytes*(#layers+1))
(*list is ended with a '0' offset)
- channel offset list guint32 (4 bytes*(#layers+1))
(*list is ended with a '0' offset)
- image layers:
- layer width guint32 (4 bytes)
- layer height guint32 (4 bytes)
- layer type enum (4 bytes)
tag guint32, used as bitmap (4 bytes)
- layer name guint8*
- properties list (same as image property list)
- hierarchy offset guint32 (4 bytes)
- layer mask offset guint32 (4 bytes)
(* Layer mask offset is either a '0', meaning the layer is not
a mask, or the position of the data in the file, if it is).
- hierarchy data:
- width guint32 (4 bytes)
- height guint32 (4 bytes)
- bpp guint32 (4 bytes)
tag guint32, used as bitmap (4 bytes)
bytes (color depth) guint32 (4 bytes)
storage (STORAGE_NONE/STORAGE_FLAT/STORAGE_TILED/STORAGE_SHM)
guint32 (4 bytes)
AutoAllocation (AUTOALLOC_NONE/AUTOALLOC_OFF/AUTOALLOC_ON) guint32
(4 bytes)
- levels offsets guint32 (4 bytes*(#levels+1))
(*terminated with a '0')
(* no levels. see item 5)
- level data (1st level: the real data. 2nd level and on ->
fake levels (empty of data). Level n has width/height half of
level n-1)
- width guint32 (4 bytes)
- height guint32 (4 bytes)
- tile offsets guint32 (4 bytes*(#tiles_per_level+1))
(*terminated with a '0')
- tile data (each tile is up to 64*64 pixels, saved in
RLE, left->right, top->bottom, pixel-depth is 8bit)
PixelAera data (each PixelArea is up to
128*128 pixels, going left->right, top->bottom)
- row data: (starting from bottom row
to top)
- tag guint32 (a bit map) (4 bytes)
- width guint32 (4 bytes)
- R value guint8 (1 byte)
- G value guint8 (1 byte)
- B value guint8 (1 byte) (*assuming
RGB, 8bit depth)
- Channel data (In case there are more channels than the default
3)
- width guint32 (4 bytes)
- height guint32 (4 bytes)
- name guint8*
- properties list (same as image property list)
- hierarchy offset guint32 (4 bytes).
(*this is merely the current position + 4. I.E. 4 bytes are used
to store a position of the channel data, which is... 4 bytes
ahead)
- hierarchy data (the tiles, same as level hierarchy data).
Summary: Points of difference in XCF implementation in Cinepaint
and GIMP
- String signature is different. Gimp's is "gimp xcf file",
which is default when no version number exist for the application.
CP's is "gimp xcf v100".
- Cinepaint uses the tag member as a bitmap to store type,
alpha and depth attributes. Gimp uses seperate members for specifing
type and alpha. Depth is 8 bits by default.
- PROP_COLOR is disregarded by CP, while it is handled by gimp.
- CP doesn't handle PROP_RESOLUTION, PROP_TATTOO, PROP_PARASITES,
PROP_UNIT, PROP_PATHS, PROP_USER_UNIT.
- Storing image data is different:
- Cinepaint stores image pixels in 'PixelAreas', sized 128*128
pixels. gimp uses 'tiles', sized 64*64 pixels.
- Cinepaint stores hierarchy attributes differently
- Within each PixelArea, Cinepaint saves the rows from bottom-to-top.
Gimp saves them from top-to-bottom.
- Gimp defaults to storing pixel data in RLE, while Cinepaint
doesn't.
GIMP XCF Documentation
http://www.mit.edu/afs/sipb/project/gimp-1.2/src/gimp-1.2.0/devel-docs/xcf.txt
Questions
to rower@movieeditor.com
Created November
30, 2003; updated December 17, 2003