/// <summary> /// MPエントリの読み出し /// </summary> /// <param name="buffer"></param> /// <param name="offsetStart">オフセット基準位置</param> /// <param name="index"></param> /// <param name="endian"></param> /// <returns></returns> private MPEntryValue[] DecodeMPEntries(byte[] buffer, int offsetStart, MPIndexIFD index, Endian endian) { int offset = offsetStart + (int)index.MPEntry.OffsetUInt32; MPEntryValue[] mpEntries = new MPEntryValue[index.NumberOfImages.OffsetUInt32]; for (int i = 0; i < mpEntries.Length; i++) { mpEntries[i] = new MPEntryValue(buffer, offset + (16 * i), endian); } return(mpEntries); }
/// <summary> /// 個別画像ユニークIDリストの読み出し /// </summary> /// <param name="buffer"></param> /// <param name="offsetStart">オフセット基準位置</param> /// <param name="index"></param> /// <param name="endian"></param> /// <returns></returns> private UniqueID[] DecodeUniqueIDs(byte[] buffer, int offsetStart, MPIndexIFD index, Endian endian) { UniqueID[] uids = null; if (index.ImageUIDList != null) { uids = new UniqueID[index.NumberOfImages.OffsetUInt32]; int offset = offsetStart + (int)index.ImageUIDList.OffsetUInt32; for (int i = 0; i < uids.Length; i++) { uids[0] = new UniqueID(buffer, offset + (33 * i), endian); } } return(uids); }
/// <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); }