About this Blog

This Blog has English posts and Japanese posts. About Mac, iOS, Objective-C, and so on.



This post is a personal translation of Henning Makholm's xcf.txt to Japanese. : Index here

The image structure always starts at offset 0 in the XCF file.

image structureは必ずXCFファイルのオフセット0[先頭]から始まります。

  byte[9] "gimp xcf "  File type magic
  byte[4] version      XCF version
                         "file" - version 0
                         "v001" - version 1
                         "v002" - version 2
  byte    0            Zero-terminator for version tag
  uint32  width        With of canvas
  uint32  height       Height of canvas
  uint32  base_type    Color mode of the image; one of
                          0: RGB color
                          1: Grayscale
                          2: Indexed color
                       (enum GimpImageBaseType in libgimpbase/gimpbaseenums.h)
  property-list        Image properties (details below)
  ,------------------- Repeat once for each layer, topmost layer first:
  | uint32 layer       Pointer to the layer structure
  uint32   0           Zero marks the end of the array of layer pointers
  ,------------------- Repeat once for each channel, in no particular order:
  | uint32 channel1    Pointer to the channel structure
  uint32   0           Zero marks the end of the array of channel pointers

byte[9] "gimp xcf " : ファイルタイプを表すマジックナンバー。
byte[4] version : XCFのバージョンを表します。"file", "v001", "v002"の3つのうちの1つ。
byte 0 : バージョンタグのゼロ終端です
uint32 width : キャンバスの幅
uint32 height : キャンバスの高さ
uint32 base_type : 画像のカラーモード。0:RGB, 1:Grayscale, 2:indexed colorのうちのいずれか。
libgimpbase/gimpbaseenums.h内で enum GimpImageBaseTypeとして定義されています。
uint32 layer : layer structureへのpointer を layerの数だけ繰り返し
ゼロ終端で、layer pointer listの終了を示します。
uint32 channel structure pointer を channelの数だけ繰り返し

The last four characters of the initial 13-character magic string are
a version indicator. The version will be higher than 2 if the correct
reconstruction of pixel data from the file requires that the reader
understands features not described in this specification. On the other
hand, optional extra information that can be safely ignored will not
cause the version to increase.


GIMP's XCF writer dynamically selects the lowest version that will
allow the image to be represented. Third-party XCF writers should do

GIMPのXCF writerは、画像に合わせて、画像を表現できる最も小さなバージョンのXCFを選択するようになっています。サードパーティ製のXCFを出力するソフトウエアも同様にすべきです。

Version numbers from v100 upwards have been used by CinePaint, which
originated as a 16-bit fork of GIMP. That format is not described
by this specification.


Image properties
The following properties are found only in the property list of the
image structure. In addition to these, the list can also contain the
properties PROP_TATTOO, PROP_PARASITES and PROP_END, described in
section 8 below.

以下に述べるpropertyは、image structureのpropertyリストにのみ現れます。これらに加えて、リストは、PROP_TATTOO, PROP_PARASITES , PROP_ENDといったpropertyを含むことができます。これらについては、Section 8で述べています。

PROP_COLORMAP (essential)


  uint32  1     The type number for PROP_COLORMAP is 1
  uint32  3n+4  The payload length
  uint32  n     The number of colors in the colormap (should be <256)
  ,------------ Repeat n times:
  | byte  r     The red component of a colormap color
  | byte  g     The green component of a colormap color
  | byte  b     The blue component of a colormap color
  Appears in all indexed images and stores the colormap. The property
  will be ignored if it is encountered in an RGB or grayscale
  image. The current GIMP will not write a colormap with RGB or
  grayscale images, but some older ones occasionally did, and readers
  should be prepared to gracefully ignore it in those cases.


  Note that in contrast to the palette data model of, for example, the
  PNG format, an XCF colormap does not contain alpha components, and
  there is no colormap entry for "transparent"; the alpha channel of
  layers that have one is always represented separately.


  The structure here is that of XCF version >= 1.  Comments in the
  GIMP source code indicate that XCF version 0 could not store indexed
  images in a sane way; contemporary Gimps will complain and
  reinterpret the pixel data as a grayscale image if they meet a
  version-0 indexed image.

このstructureは、XCFバージョン1以上のものです。GIMPのソースコード中のコメントによれば、XCFのver.0は、indexed imageをまっとうなやり方では保存できなかったようです。現行のGIMPがXCF ver0のindexed imageをひらく時は警告とともに、グレースケール形式の画像として再解釈・展開します。、

  Beware that the payload length of the PROP_COLORMAP in particular
  cannot be trusted: some historic releases of GIMP erroneously
  wrote n+4 instead of 3n+4 into the length word (but still actually
  followed it by 3n+4 bytes of payload).




  uint32  17  The type number for PROP_COMPRESSION is 17
  uint32  1   One byte of payload
  byte    c   Compression indicator; one of
                0: No compression
                1: RLE encoding
                2: (Never used, but reserved for zlib compression)
                3: (Never used, but reserved for some fractal compression)
  Defines the encoding of pixels in tile data blocks in the entire XCF
  file. See section 6 below for details.

XCFファイル全体の、データブロックにおけるピクセルデータの圧縮方式を表します。詳しくはsection 6 で述べます。

  Note that unlike most other properties whose payload is always a
  small integer, PROP_COMPRESSION does _not_ pad the value to a full
  32-bit integer.

他のpropertyと違い、このpropertyのpayloadはsmall integer[1バイト]です。余分にバイトを書き込んで32bit長にする、ということはしていません。

  Contemporary Gimps always write files with c=1. It is unknown to the
  author of this document whether versions that wrote completely
  uncompressed (c=0) files ever existed.


PROP_GUIDES (editing state)


  uint32  18  The type number for PROP_GUIDES is 18
  uint32  5*n Five bytes of payload per guide
  ,---------- Repeat n times:
  | int32 c   Guide coordinate
  | byte  o   Guide orientation; one of
  |            1: The guide is horizontal, and c is a y coordinate
  |            2: The guide is vertical, and c is an x coordinate
  Appears if any guides have been defined.


  Some old XCF files define guides with negative coordinates; those
  should be ignored by readers.


PROP_RESOLUTION (not editing state, but not _really_ essential either)
  uint32  19  The type number for PROP_RESOLUTION is 19
  uint32  8   Eight bytes of payload
  float   x   Horizontal resolution in pixels per 25.4 mm
  float   y   Vertical resolution in pixels per 25.4 mm
  Gives the intended physical size of the image's pixels.


  Note that for many images, such as graphics created for the web, the
  creator does not really have an intended resolution in mind but
  intends the image to be shown at whatever the natural resolution of
  the viewer's monitor is. Similarly, photographs commonly do not have
  a well-defined target size and are intended to be scaled to fit the
  available space instead. Therefore readers should not interpret the
  information in this property too rigidly; GIMP writes it to XCF
  files unconditionally, even if the user has not explicitly chosen a


PROP_UNIT (editing state)
  uint32  22  The type number for PROP_UNIT is 22
  uint32  4   Four bytes of payload
  uint32  c   Magic number specifying the unit; one of
                1: Inches (25.4 mm)
                2: Millimeters (1 mm)
                3: Points (127/360 mm)
                4: Picas (127/30 mm)
  Specifies the units used to specify resolution in the Scale Image
  and Print Size dialogs.  Note that this is used only in the user
  interface; the PROP_RESOLUTION property is always stored in pixels
  per 25.4 mm.


  Instead of this property, PROP_USER_UNIT can be used to specify a
  unit not on the list of standard units.


  uint32    23   The type number for PROP_PATHS is 23
  uint32    len  The total length of the following payload
  uint32    a    The index of the active path
  uint32    n    The number of paths that follow
  Each path has one of three formats


    Format 1:   Format 2:   Format 3:
     string      string      string     name
     uint32      uint32      uint32     locked
     byte        byte        byte       state    4 if closed, 2 otherwise
     uint32      uint32      uint32     closed
     uint32      uint32      uint32     n        The number of points
     uint32=1    uint32=2    uint32=3   v        A version indicator
                 uint32      uint32     dummy    Ignored; always set to 1
                             uint32     tattoo   0 if none, or see PROP_TATTOO
     ,---------- ,---------- ,------------------ Repeat for n points:
     | int32     | int32     | int32    typ      Type of point; one of
     |           |           |                    0: an anchor
     |           |           |                    1: a Bezier control point
     | int32     | float     | float    x        X coordinate
     | int32     | float     | float    y        Y coordinate
     `--         `--         `--
  This format is used to save path data if all paths in the image are
  continuous sequences of Bezier strokes. Otherwise PROP_VECTORS is
  used instead.


  (Hmmm... PROP_PATHS cannot represent parasites for paths, but the
  XCF writer does not check whether all paths are parasite-less when
  choosing which property to use, so path parasites may be lost upon


  There may be paths that declare a length of 0 points; these should
  be ignored.


PROP_USER_UNIT (editing state)
  uint32  24      The type number for PROP_USER_UNIT is 24
  uint32  length  The total length of the following payload
  float   factor  25.4 mm divided by the length of the unit
  uint32  digits  The number of decimal digits used with the unit
  string  id      An identifier for the unit
  string  sym     The short symbol for the unit
  string  abbr    The abbreviation for the unit
  string  sing    The name of the unit in singular
  string  plur    The name of the unit in plural
  An alternative to PROP_UNIT which allows the use of units not on the
  standard list.


  uint32       25         The type number for PROP_VECTORS is 25
  uint32       length     The total length of the following payload
  uint32       1          A version tag; so far always 1
  uint32       a          The index of the active path
  uint32       n          The number of paths that follow
  ,---------------------- Repeat n times:
  | string     name       Name of the path
  | uint32     tattoo     Tattoo of the path (see PROP_TATTOO), or 0
  | uint32     visible
  | uint32     linked
  | uint32     m          The number of parasites for the path
  | uint32     k          The number of strokes in the first path
  | ,-------------------- Repeat m times:
  | | parasite ...        In same format as in PROP_PARASITES (q.v.)
  | `--
  | ,-------------------- Repeat k times:
  | | uint32   1          The stroke is a Bezier stroke (p.t., all are)
  | | uint32   closed     Closed flag
  | | uint32   na         Number of floats given for each point;
  | |                     must be >= 2 and <= 6.
  | | uint32   np         Number of control points for this stroke
  | | ,------------------ Repeat np times:
  | | | uint32 type       Type of the first point; one of
  | | |                     0: an anchor
  | | |                     1: a Bezier control point
  | | | float  x          X coordinate
  | | | float  y          Y coordinate
  | | | float  pressure   Only if na >= 3; otherwise defaults to 1.0
  | | | float  xtilt      Only if na >= 4; otherwise defaults to 0.5
  | | | float  ytilt      Only if na >= 5; otherwise defaults to 0.5
  | | | float  wheel      Only if na == 6; otherwise defaults to 0.5
  | | `--
  | `--
  Appears unless all paths can be stored in the PROP_PATHS format.


  GIMP's XCF reader checks that the total size of all path
  specifications in the property precisely equals the length word, so
  it is safe for a reader to use the length word to skip the property
  without parsing the individual parasites. (Note that this is _not_
  the case for PROP_PATHS).


0 件のコメント: