Exemplo n.º 1
0
        private int _GetSize()
        {
            int _size = 0;

            for (Tiff.Ifd _idf = this.ImageFileDirectory; _idf != null; _idf = _idf.NextIfd)
            {
                if (_idf.Offset + _idf.Size > _size)
                {
                    _size = _idf.Offset + _idf.Size;
                }

                Tiff.IfdEntry _stripOffsetsTag = null, _stripByteCountsTag = null;
                Tiff.IfdEntry _freeOffsets = null, _freeByteCounts = null;
                Tiff.IfdEntry _tileOffsets = null, _tileByteCounts = null;
                foreach (IfdEntry _entry in _idf)
                {
                    if (_entry.DataOffset + _entry.DataSize > _size)
                    {
                        _size = _entry.DataOffset + _entry.DataSize;
                    }
                    switch (_entry.Tag)
                    {
                    case TiffTags.STRIPOFFSETS:
                        _stripOffsetsTag = _entry;
                        break;

                    case TiffTags.STRIPBYTECOUNTS:
                        _stripByteCountsTag = _entry;
                        break;

                    case TiffTags.FREEOFFSETS:
                        _freeOffsets = _entry;
                        break;

                    case TiffTags.FREEBYTECOUNTS:
                        _freeByteCounts = _entry;
                        break;

                    case TiffTags.TILEOFFSETS:
                        _tileOffsets = _entry;
                        break;

                    case TiffTags.TILEBYTECOUNTS:
                        _tileByteCounts = _entry;
                        break;
                    }
                }
                foreach (IfdEntry[] _item in new Tiff.IfdEntry[][] { new[] { _stripOffsetsTag, _stripByteCountsTag }, new[] { _freeOffsets, _freeByteCounts }, new[] { _tileOffsets, _tileByteCounts } })
                {
                    if (_item[0] != null && _item[1] != null && _item[0].Length == _item[1].Length)
                    {
                        for (int i = 0; i < _item[0].Length; i++)
                        {
                            int _dataOffset = Convert.ToInt32(_item[0][i]);
                            int _dataSize   = Convert.ToInt32(_item[1][i]);
                            if (_dataOffset + _dataSize > _size)
                            {
                                _size = _dataOffset + _dataSize;
                            }
                        }
                    }
                }
            }
            return(_size);
        }
Exemplo n.º 2
0
 public static Tiff.Ifd FromPtr(IntPtr ptr, IntPtr baseAddr)
 {
     Tiff.Ifd _idf = new Tiff.Ifd();
     _idf.Load(ptr, baseAddr);
     return(_idf);
 }