private static Tiff FromPtr(IntPtr ptr) { Tiff _tiff = new Tiff { _header = (TiffHeader)Marshal.PtrToStructure(ptr, typeof(TiffHeader)) }; if (_tiff._header.magic == MagicValues.BigEndian) { throw new NotSupportedException(); } _tiff._ifd = Ifd.FromPtr((IntPtr)(ptr.ToInt64() + _tiff._header.dirOffset), ptr); return(_tiff); }
private void Load(IntPtr ptr, IntPtr baseAddr) { ushort _count = (ushort)Marshal.PtrToStructure(ptr, typeof(ushort)); IntPtr _ptr = (IntPtr)(ptr.ToInt64() + sizeof(ushort)); for (int i = 0, _size = Marshal.SizeOf(typeof(TiffDirEntry)); i < _count; i++, _ptr = (IntPtr)(_ptr.ToInt64() + _size)) { this.Add(Tiff.IfdEntry.FromPtr(_ptr, baseAddr)); } int _nextIdfOffset = (int)Marshal.PtrToStructure(_ptr, typeof(int)); if (_nextIdfOffset != 0) { this.NextIfd = Ifd.FromPtr((IntPtr)(baseAddr.ToInt64() + _nextIdfOffset), baseAddr); } this.Offset = (int)(ptr.ToInt64() - baseAddr.ToInt64()); this.Size = 6 + Marshal.SizeOf(typeof(Tiff.TiffDirEntry)) * _count; }