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

A hierarchy contains data for a rectangular array of pixels. It is
pointed to from a layer or channel structure.

hierarchy structureはピクセルの2次元配列を保持しています。layer structure内またはchannel structure内のpointerがその位置を記録しています。

  uint32   width   The with of the pixel array
  uint32   height  The height of the pixel array
  uint32   bpp     The number of bytes per pixel given
  uint32   lptr    Pointer to the "level" structure
  ,--------------- Repeat zero or more times
  | uint32 dlevel  Pointer to an unused level structure
  uint32   0       A zero ends the list of level pointers


The width, height, and bpp values are for consistency checking; their
correct values can always be inferred from the context, and are
checked when GIMP reads the XCF file.


For some unknown historical reason, the hierarchy structure contains
an extra indirection to a series of "level" structures, described
below. Only the first level structure is used by GIMP's XCF
reader, except that the reader checks that a terminating zero for the
level-pointer list can be found. GIMP's XCF writer creates a
series of dummy level structures (with no tile pointers), each
declaring a height and width half of the previous one (rounded down),
until the height and with are both less than 64. Thus, for a layer of
3 x 266 pixels, this series of levels will be saved:

歴史的経緯から、hierarchy structureは余分なlevel structureへの間接参照を含んでいます。これについて以下に述べます。GIMPのXCF readerは、first level structureのみを使用します。ただし、level pointers listのゼロ終端が存在するかを確かめるため、全てのlevel structureをチェックします。GIMPのXCF writerは、tile pointerを持たない、ダミーのlevel structureを作ります。それぞれのlevel structureは、1つ前のlevel structureの半分の高さと幅(端数切捨て)を持つとして宣言されます。幅と高さが64未満になるまで、次々とこのようなダミーの構造体が書き込まれます。つまり、3x266 pxのレイヤーには、以下のようなレベル構造体が保存されます。

   A level of 3 x 266 pixels, with 5 tiles: the actually used one
   A level of 1 x 133 pixels with no tiles
   A level of 0 x 66 pixels with no tiles
   A level of 0 x 33 pixels with no tiles


Third-party XCF writers should probably mimic this entire structure;
robust XCF readers should have no reason to even read past the pointer
to the first level structure.

サードパーティ製のXCF writerは、このstructure生成を正確に真似るべきです。readerに関しては、第一階層のみを読みこめばいいでしょう。

The level structure is laid out as follows:

  uint32   width  The width of the pixel array
  uint32   height The height of the pixel array
  ,-------------- Repeat for each of the ceil(width/64)*ceil(height/64) tiles
  | uint32 tptr   Pointer to tile data
  uint32   0      A zero marks the end of the array of tile pointers


The width and height must be the same as the ones recorded in the
hierarchy structure (except for the aforementioned dummy levels).

高さと幅は、含まれるhierarchy structureと同じでないといけません。(上述したダミーレベルを除く)

The pixels in the hierarchy are organized in a grid of "tiles", each
with a width and height of up to 64 pixels. The only tiles that have a
width less than 64 are those in the rightmost column, and the only
tiles that have a height less than 64 are those in the bottommost row.
Thus, a layer measuring 200 x 150 pixels will be divided into 12

 | Tile 0: 64 x 64 | Tile 1: 64 x 64 | Tile 2: 64 x 64  | Tile 3: 8 x 64  |
 | Tile 4: 64 x 64 | Tile 5: 64 x 64 | Tile 6: 64 x 64  | Tile 7: 8 x 64  |
 | Tile 8: 64 x 22 | Tile 9: 64 x 22 | Tile 10: 64 x 22 | Tile 11: 8 x 22 |

hierarchy structureのピクセルは、tilesと呼ばれる格子で管理されています。右端のtileには、幅が64px以下のものが、最下段のtileには、高さが64px以下のものがおさめられます。>したがって、200x150pxのピクセルデータは以下の様なタイルに分割されます。[表は原文のものを見てください]

As can be seen from this example, the tiles appear in the XCF file in
row-major, top-to-bottom, left-to-right order. The dimensions of the
individual tiles are not stored explicitly in the XCF file, but must
be computed by the reader.

個々のタイルの大きさはXCF内に明示的に保存されないので、XCF readerが計算する必要があります。

The tiles that are pointed to by a single level structure must be
contiguous in the XCF file, because GIMP's XCF reader uses the
difference between two subsequent tile pointers to judge the amount of
memory it needs to allocate for internal data structures.

tileと、それを指し示すsingle level structureはXCFファイルの中で隣接していないといけません。なぜなら、GIMPのXCFリーダーはメモリ上に展開する時に必要なメモリ容量を計算する時に2つの連続したtileポインターの差を利用するからです。[?]

0 件のコメント: