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);
        }
Beispiel #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);
        }
Beispiel #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
 }          
 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();
     }
 }
Beispiel #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
        }
Beispiel #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();
                }
            }
        }
 public ExifAttribute(uint tag, ExifHeader exifHeader)
 {
     Tag = tag;
     ExifHeader = exifHeader;
 }
Beispiel #8
0
 public bool HasUnsetProperties(ExifHeader headerType) => _unsetProperties[headerType] > 0;
Beispiel #9
0
 public static bool HasMatchingProperty(uint tag, ExifHeader headerType)
 {
     var exifAttribute = new ExifAttribute(tag, headerType);
     return _exifAttributesCache.ContainsKey(exifAttribute);
 }
Beispiel #10
0
 public bool HasUnsetProperties(ExifHeader headerType) => _unsetProperties[headerType] > 0;
Beispiel #11
0
        public static bool HasMatchingProperty(uint tag, ExifHeader headerType)
        {
            var exifAttribute = new ExifAttribute(tag, headerType);

            return(_exifAttributesCache.ContainsKey(exifAttribute));
        }
 public ExifAttribute(uint tag, ExifHeader exifHeader)
 {
     Tag        = tag;
     ExifHeader = exifHeader;
 }