/// <summary> /// MP個別情報IFDの読み出し /// </summary> /// <param name="buffer"></param> /// <param name="o">オフセット</param> /// <param name="offsetStart">オフセット基準位置</param> /// <param name="endian"></param> /// <returns></returns> private MPIndividualAttributesIFD DecodeMPIndAttrIFD(byte[] buffer, int o, int offsetStart, Endian endian) { // バイト列からIFDのフィールド個数を読み込み MPIndividualAttributesIFD indAttr = new MPIndividualAttributesIFD { Count = BitConverterEx.ToUInt16(buffer, o + 0, endian), }; // count個分フィールドを読み込み、Tagの値に従って適当なプロパティに設定 for (int i = 0; i < indAttr.Count; i++) { int offset = o + 2 * (12 * i); IFD ifd = new IFD(buffer, o + 2 + (12 * i), offsetStart, endian); switch (ifd.Tag) { case 45056: indAttr.MPFVersion = ifd; break; case 45313: indAttr.MPIndividualNum = ifd; break; case 45569: indAttr.PanOrientation = ifd; break; case 45570: indAttr.PanOverlap_H = ifd; break; case 45571: indAttr.PanOverlap_V = ifd; break; case 45572: indAttr.BaseViewpointNum = ifd; break; case 45573: indAttr.ConvergenceAngle = ifd; break; case 45574: indAttr.BaselineLength = ifd; break; case 45575: indAttr.VerticalDivergence = ifd; break; case 45576: indAttr.AxisDistance_X = ifd; break; case 45577: indAttr.AxisDistance_Y = ifd; break; case 45578: indAttr.AxisDistance_Z = ifd; break; case 45579: indAttr.YawAngle = ifd; break; case 45580: indAttr.PitchAngle = ifd; break; case 45581: indAttr.RollAngle = ifd; break; default: throw new Exception(string.Format("無効なMP個別情報IFDのTag({0})です", ifd.Tag)); } } // 普通は0 indAttr.NextIFDOffset = BitConverterEx.ToUInt32(this.buffer, o + 2 + (12 * indAttr.Count), endian); return(indAttr); }
/// <summary> /// MPインデックスIFDの読み出し /// </summary> /// <param name="buffer"></param> /// <param name="o">オフセット</param> /// <param name="endian"></param> /// <returns></returns> private MPIndexIFD DecodeMPIndexIFD(byte[] buffer, int o, int offsetStart, Endian endian) { // バイト列から読み込み MPIndexIFD index = new MPIndexIFD { Count = BitConverterEx.ToUInt16(buffer, o, endian), MPFVersion = new IFD(buffer, o + 2, offsetStart, endian), NumberOfImages = new IFD(buffer, o + 14, offsetStart, endian), MPEntry = new IFD(buffer, o + 26, offsetStart, endian), }; // タグ番号をチェック if (index.MPFVersion.Tag != 45056) { throw new Exception("MPFVersionのデコードに失敗しました"); } if (index.NumberOfImages.Tag != 45057) { throw new Exception("NumberOfImagesのデコードに失敗しました"); } if (index.MPEntry.Tag != 45058) { throw new Exception("MPEntryのデコードに失敗しました"); } // 個別画像ユニークIDリスト以下は省略されて存在しないかもしれない if (index.Count > 3) { index.ImageUIDList = new IFD(buffer, o + 38, offsetStart, endian); index.TotalFrames = new IFD(this.buffer, o + 50, offsetStart, endian); index.NextIFDOffset = BitConverterEx.ToUInt32(buffer, o + 62, endian); } else if (index.Count == 3) { index.ImageUIDList = null; index.TotalFrames = null; index.NextIFDOffset = BitConverterEx.ToUInt32(buffer, o + 38, endian); } else { throw new InvalidOperationException("MPインデックスIFDの解析に失敗しました"); } return(index); }