コード例 #1
0
        public void ReadTag(ushort tag, ExifHeader headerType, ExifPhoto photo)
        {
            var currentPos = _jpegFileReader.BaseStream.Position;
            var fieldtype = (ExifFieldType)_binaryReader.ReadUInt16();
            var length = _binaryReader.ReadUInt32();
            var value = _binaryReader.ReadUInt32();
            switch (fieldtype) {

                case ExifFieldType.AsciiStrings:
                    SeekToTiffHeaderRelativeOffset(value);
                    photo.SetMatchingProperty(tag, headerType, _binaryReader.ReadString((int)length));
                    break;

                case ExifFieldType.UnsignedRational:
                    SeekToTiffHeaderRelativeOffset(value);
                    photo.SetMatchingProperty(tag, headerType, _binaryReader.ReadUnsignedRational());
                    break;

                case ExifFieldType.UnsignedLong:
                    photo.SetMatchingProperty(tag, headerType, value);
                    break;

            }
            _jpegFileReader.BaseStream.Seek(currentPos + 2 + 4 + 4, SeekOrigin.Begin);
        }
コード例 #2
0
        public void ReadTag(ushort tag, ExifHeader headerType, ExifPhoto photo)
        {
            var currentPos = _jpegFileReader.BaseStream.Position;
            var fieldtype  = (ExifFieldType)_binaryReader.ReadUInt16();
            var length     = _binaryReader.ReadUInt32();
            var value      = _binaryReader.ReadUInt32();

            switch (fieldtype)
            {
            case ExifFieldType.AsciiStrings:
                SeekToTiffHeaderRelativeOffset(value);
                photo.SetMatchingProperty(tag, headerType, _binaryReader.ReadString((int)length));
                break;

            case ExifFieldType.UnsignedRational:
                SeekToTiffHeaderRelativeOffset(value);
                photo.SetMatchingProperty(tag, headerType, _binaryReader.ReadUnsignedRational());
                break;

            case ExifFieldType.UnsignedLong:
                photo.SetMatchingProperty(tag, headerType, value);
                break;
            }
            _jpegFileReader.BaseStream.Seek(currentPos + 2 + 4 + 4, SeekOrigin.Begin);
        }
コード例 #3
0
 public void SetMatchingProperty(uint tag, ExifHeader headerType, object value)
 {
     var exifAttribute = new ExifAttribute(tag, headerType);
     if (!_exifAttributesCache.ContainsKey(exifAttribute)) return;
     var propertyName = _exifAttributesCache[exifAttribute];
     var propertyInfo = this.GetType().GetProperty(propertyName);
     propertyInfo.SetValue(this, value, null);
     _unsetProperties[headerType]--; //this is based on the assumption that Exif tags in the jpg are unique
 }          
コード例 #4
0
 public void ReadIFDHeader(ExifHeader headerType, uint headerPosition, ExifPhoto photo)
 {
     SeekToTiffHeaderRelativeOffset(headerPosition);
     var numberOfTags = _binaryReader.ReadUInt16();
     for (var i = 0; i < numberOfTags; i++) {
         var tag = _binaryReader.ReadUInt16();
         if (ExifPhoto.HasMatchingProperty(tag, headerType)) {
             ReadTag(tag, headerType, photo);
             if (!photo.HasUnsetProperties(headerType)) break;
         } else
             MoveToTheNextTag();
     }
 }
コード例 #5
0
        public void SetMatchingProperty(uint tag, ExifHeader headerType, object value)
        {
            var exifAttribute = new ExifAttribute(tag, headerType);

            if (!_exifAttributesCache.ContainsKey(exifAttribute))
            {
                return;
            }
            var propertyName = _exifAttributesCache[exifAttribute];
            var propertyInfo = this.GetType().GetProperty(propertyName);

            propertyInfo.SetValue(this, value, null);
            _unsetProperties[headerType]--; //this is based on the assumption that Exif tags in the jpg are unique
        }
コード例 #6
0
        public void ReadIFDHeader(ExifHeader headerType, uint headerPosition, ExifPhoto photo)
        {
            SeekToTiffHeaderRelativeOffset(headerPosition);
            var numberOfTags = _binaryReader.ReadUInt16();

            for (var i = 0; i < numberOfTags; i++)
            {
                var tag = _binaryReader.ReadUInt16();
                if (ExifPhoto.HasMatchingProperty(tag, headerType))
                {
                    ReadTag(tag, headerType, photo);
                    if (!photo.HasUnsetProperties(headerType))
                    {
                        break;
                    }
                }
                else
                {
                    MoveToTheNextTag();
                }
            }
        }
コード例 #7
0
 public ExifAttribute(uint tag, ExifHeader exifHeader)
 {
     Tag = tag;
     ExifHeader = exifHeader;
 }
コード例 #8
0
 public bool HasUnsetProperties(ExifHeader headerType) => _unsetProperties[headerType] > 0;
コード例 #9
0
 public static bool HasMatchingProperty(uint tag, ExifHeader headerType)
 {
     var exifAttribute = new ExifAttribute(tag, headerType);
     return _exifAttributesCache.ContainsKey(exifAttribute);
 }
コード例 #10
0
 public bool HasUnsetProperties(ExifHeader headerType) => _unsetProperties[headerType] > 0;
コード例 #11
0
        public static bool HasMatchingProperty(uint tag, ExifHeader headerType)
        {
            var exifAttribute = new ExifAttribute(tag, headerType);

            return(_exifAttributesCache.ContainsKey(exifAttribute));
        }
コード例 #12
0
 public ExifAttribute(uint tag, ExifHeader exifHeader)
 {
     Tag        = tag;
     ExifHeader = exifHeader;
 }