SourceForge.net Logo LinuxFund.org Logo
Home Press Mailing Lists Documentation Screenshots People SourceForge Downloads

XCF File Format

by Amit Dor

  1. "gimp xcf file" guint8* (14 bytes)
    "gimp xcf v100"
  2. image width guint32 (4 bytes)
  3. image height guint32 (4 bytes)
  4. 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)
  5. properties list: contains 0 or more sets of the following (1-3):
    1. PropType enum (4 bytes)
    2. size guint32 (4 bytes)
    3. data (optional, depending on PropType)
    4. PROP_END + size (8 bytes)
  6. layer offsets list guint32 (4 bytes*(#layers+1))
    (*list is ended with a '0' offset)
  7. channel offset list guint32 (4 bytes*(#layers+1))
    (*list is ended with a '0' offset)
  8. image layers:
    1. layer width guint32 (4 bytes)
    2. layer height guint32 (4 bytes)
    3. layer type enum (4 bytes)
      tag guint32, used as bitmap  (4 bytes)
    4. layer name guint8*
    5. properties list (same as image property list)
    6. hierarchy offset guint32 (4 bytes)
    7. 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).
    8. hierarchy data:
      1. width guint32 (4 bytes)
      2. height guint32 (4 bytes)
      3. 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)
      4. levels offsets guint32 (4 bytes*(#levels+1))
        (*terminated with a '0')
        (* no levels. see item 5)
      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)
        1. width guint32 (4 bytes)
        2. height guint32 (4 bytes)
        3. tile offsets guint32 (4 bytes*(#tiles_per_level+1))
          (*terminated with a '0')
        4.  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)
          1. row data: (starting from bottom row to top)
            1. tag guint32 (a bit map) (4 bytes)
            2. width guint32 (4 bytes)
            3. R value guint8 (1 byte)
            4. G value guint8 (1 byte)
            5. B value guint8 (1 byte) (*assuming RGB, 8bit depth)
      6. Channel data (In case there are more channels than the default 3)
        1. width guint32 (4 bytes)
        2. height guint32 (4 bytes)
        3. name guint8*
        4. properties list (same as image property list)
        5. 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)
        6. hierarchy data (the tiles, same as level hierarchy data).

Summary: Points of difference in XCF implementation in Cinepaint and GIMP

  1. 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".
  2. 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.
  3. PROP_COLOR is disregarded by CP, while it is handled by gimp.
  4. CP doesn't handle PROP_RESOLUTION, PROP_TATTOO, PROP_PARASITES, PROP_UNIT, PROP_PATHS, PROP_USER_UNIT.
  5. Storing image data is different:
    1. Cinepaint stores image pixels in 'PixelAreas', sized 128*128 pixels. gimp uses 'tiles', sized 64*64 pixels.
    2. Cinepaint stores hierarchy attributes differently
    3. Within each PixelArea, Cinepaint saves the rows from bottom-to-top. Gimp saves them from top-to-bottom.
    4. 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