예제 #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;
 }