DMフォーマット
提供: Eospedia
		
		
		
GATAN DIgital Micrographのフォーマットです。 開発の際に、[http://www.er-c.org/cbb/info/dmformat/] にある情報を理解するためにこちらにまとめました。
目次
DM3
画像は、ヘッダー、タグディレクトリ、ファイルの最後を示したNULL(8文字)からなっている。タグディレクトリは、タグか複数のタグディレクトリを階層構造として持つ事ができる。
画像は、"ImageList"と名付けられたtag directoryに格納されている。一つ以上の画像を格納できる。
Header
 version   i4be    DM version = 3
 rootlen   i4be    Size of root tag directory in bytes = file length - 16
 byteord   i4be    Byte order, 0 = big endian (Mac) order,
                               1 = little endian (PC) order
Root tag directory
sortf i1 Sorted, 1 = sorted (normally = 1) closef i1 Closed, 1 = open (normally = 0) ntags i4be Number of tags in root directory (12h = 18)
Tags and tag directories in root tag directory
下記が繰り返される
tag i1 tag, 14h or 15h or 0 for end of file (0x14, 0x15, 0x00) ltname i2be tag name length in bytes, may be 0 tname a tag name (length ltname), may be absent ... tag directory or tag data
ファイルの最後
8*00 End of file is marked with 8 nulls
例(全体)
 00 00 00 03  バージョン  
 00 22 59 b9   ファイルサイズ - 16
 00 00 00 00  バイトオーダー
 01                      Root tag: Stored
 00                      Root tag: Closed
 00 00 00 12  Root tagの数
 15       TagID
 00 11                TagNameのバイト数  
 41 70 70  6c 69 63 61  74 69 6f 6e TagName("Application")
 ......
 00 00 00 00 00 00 00 00  ファイルの終わり
Tag directories と Tags
Root tag directoryや下位層のtag directoriesにおけるタグやタグディレクトリ 0x14 = 20 : タグディレクトリ(更に下位にタグディレクトリがある) 0x15 = 21 : タグ 0x00 = 00 : ファイルの終了
Tag directories
例
14 00 12 44 6f 63 75 6d 65 6e 74 4f 62 6a 65 63 74 4c 69 73 74 00 00 00 00 00 01 ......
 14             i1      identifies tag directory (14h = 20)
 00 12        i2be    bytes in tag name (ltname), may be 0
 44 6f 63 75  6d 65 6e 74  4f 62 6a 65  63 74 4c 69  73 74
                a       tag name, length ltname "DocumentObjectList"  ここまでは共通
 00             i1      1 = sorted? (can be 0 or 1) タグディレクトリの場合には下記が入ってくる
 00             i1      0 = closed?, 1 = open (normally = 0)
 00 00 00 01    i4be    number of tags in tag directory (01h = 1). Can be 0
=
DM4
DM4フォーマットは、DM3フォーマットに非常によく似ている。4バイト整数ではなく、8バイト整数を用い、2Gバイトを超えたファイルにも対応している。それぞれのタグのバイト数をもつことにより、知らないタグに関しても無視することができる。
Header
version i4be rootLength i8be byteOrder i4be
