TiffEntryBE(ref FileMap f, UInt32 offset, UInt32 up_offset) { parent_offset = up_offset; own_data = null; empty_data = 0; file = f; type = TiffDataType.TIFF_UNDEFINED; // We set type to undefined to avoid debug assertion errors. byte[] temp_data = f.getData(offset, 8); tag = (TiffTag)get2BE(temp_data, 0); type = (TiffDataType)get2BE(temp_data, 2); count = get4BE(temp_data, 4); if ((int)type > 13) { TiffParserException.ThrowTPE("Error reading TIFF structure. Unknown Type " + type + " encountered."); } bytesize = (UInt64)count << (int)Data.datashifts[(int)type]; if (bytesize > UInt32.MaxValue) { TiffParserException.ThrowTPE("TIFF entry is supposedly " + bytesize + " bytes"); } if (bytesize == 0) // Better return empty than null-dereference later { data = empty_data; } else if (bytesize <= 4) { data = f.getDataWrt(offset + 8, bytesize); } else { // offset data_offset = get4BE(f.getData(offset + 8, 4), 0); data = f.getDataWrt(data_offset, bytesize); } }
public void fetchData() { data = file?.getDataWrt(data_offset, bytesize); }