Example #1
0
        public Collection <IExifValue> Read(byte[] data)
        {
            var result = new Collection <IExifValue>();

            if (data == null || data.Length == 0)
            {
                return(result);
            }

            _reader = new EndianReader(data);

            if (_reader.ReadString(4) == "Exif")
            {
                if (_reader.ReadShortMSB() != 0)
                {
                    return(result);
                }

                _startIndex = 6;
            }

            _isLittleEndian = _reader.ReadString(2) == "II";

            if (ReadShort() != 0x002A)
            {
                return(result);
            }

            var ifdOffset = ReadLong();

            AddValues(result, ifdOffset);

            var thumbnailOffset = ReadLong();

            ReadThumbnail(thumbnailOffset);

            if (_exifOffset != 0)
            {
                AddValues(result, _exifOffset);
            }

            if (_gpsOffset != 0)
            {
                AddValues(result, _gpsOffset);
            }

            return(result);
        }
Example #2
0
        public void Read(byte[] data)
        {
            Values.Clear();
            InvalidTags.Clear();

            if (data == null || data.Length == 0)
            {
                return;
            }

            _reader = new EndianReader(data);

            if (_reader.ReadString(4) == "Exif")
            {
                if (_reader.ReadShortMSB() != 0)
                {
                    return;
                }

                _startIndex = 6;
            }

            _isLittleEndian = _reader.ReadString(2) == "II";

            if (ReadShort() != 0x002A)
            {
                return;
            }

            var ifdOffset = ReadLong();

            AddValues(Values, ifdOffset);

            var thumbnailOffset = ReadLong();

            ReadThumbnail(thumbnailOffset);

            if (_exifOffset != 0)
            {
                AddValues(Values, _exifOffset);
            }

            if (_gpsOffset != 0)
            {
                AddValues(Values, _gpsOffset);
            }
        }
Example #3
0
 private ushort ReadShort() => (_isLittleEndian ? _reader.ReadShortLSB() : _reader.ReadShortMSB()) ?? 0;