Пример #1
0
        private Collection <int> GetIndexes(ExifParts part, ExifTag[] tags)
        {
            if (!EnumHelper.HasFlag(_allowedParts, part))
            {
                return(new Collection <int>());
            }

            Collection <int> result = new Collection <int>();

            for (int i = 0; i < _values.Count; i++)
            {
                ExifValue value = _values[i];

                if (!value.HasValue)
                {
                    continue;
                }

                int index = Array.IndexOf(tags, value.Tag);
                if (index > -1)
                {
                    result.Add(i);
                }
            }

            return(result);
        }
Пример #2
0
        private List <int> GetIndexes(ExifParts part, ExifTag[] tags)
        {
            if (((int)this.allowedParts & (int)part) == 0)
            {
                return(new List <int>());
            }

            var result = new List <int>();

            for (int i = 0; i < this.values.Count; i++)
            {
                ExifValue value = this.values[i];

                if (!value.HasValue)
                {
                    continue;
                }

                int index = Array.IndexOf(tags, value.Tag);
                if (index > -1)
                {
                    result.Add(i);
                }
            }

            return(result);
        }
Пример #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExifWriter"/> class.
 /// </summary>
 /// <param name="values">The values.</param>
 /// <param name="allowedParts">The allowed parts.</param>
 public ExifWriter(IList <ExifValue> values, ExifParts allowedParts)
 {
     this.values       = values;
     this.allowedParts = allowedParts;
     this.ifdIndexes   = this.GetIndexes(ExifParts.IfdTags, ExifTags.Ifd);
     this.exifIndexes  = this.GetIndexes(ExifParts.ExifTags, ExifTags.Exif);
     this.gpsIndexes   = this.GetIndexes(ExifParts.GPSTags, ExifTags.Gps);
 }
Пример #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ExifWriter"/> class.
 /// </summary>
 /// <param name="values">The values.</param>
 /// <param name="allowedParts">The allowed parts.</param>
 public ExifWriter(IList <IExifValue> values, ExifParts allowedParts)
 {
     this.values       = values;
     this.allowedParts = allowedParts;
     this.ifdValues    = this.GetPartValues(ExifParts.IfdTags);
     this.exifValues   = this.GetPartValues(ExifParts.ExifTags);
     this.gpsValues    = this.GetPartValues(ExifParts.GpsTags);
 }
Пример #5
0
 public ExifWriter(Collection <ExifValue> values, ExifParts allowedParts)
 {
     this.values       = values;
     this.allowedParts = allowedParts;
     this.ifdIndexes   = this.GetIndexes(ExifParts.IfdTags, IfdTags);
     this.exifIndexes  = this.GetIndexes(ExifParts.ExifTags, ExifTags);
     this.gpsIndexes   = this.GetIndexes(ExifParts.GPSTags, GPSTags);
 }
Пример #6
0
        public ExifWriter(Collection <ExifValue> values, ExifParts allowedParts)
        {
            _values       = values;
            _allowedParts = allowedParts;

            _ifdIndexes  = GetIndexes(ExifParts.IfdTags, _IfdTags);
            _exifIndexes = GetIndexes(ExifParts.ExifTags, _ExifTags);
            _gPSIndexes  = GetIndexes(ExifParts.GPSTags, _GPSTags);
        }
Пример #7
0
        public ExifWriter(Collection <ExifValue> values, ExifParts allowedParts, bool bestPrecision)
        {
            _Values        = values;
            _AllowedParts  = allowedParts;
            _BestPrecision = bestPrecision;

            _IfdIndexes  = GetIndexes(ExifParts.IfdTags, _IfdTags);
            _ExifIndexes = GetIndexes(ExifParts.ExifTags, _ExifTags);
            _GPSIndexes  = GetIndexes(ExifParts.GPSTags, _GPSTags);
        }
Пример #8
0
        private List <IExifValue> GetPartValues(ExifParts part)
        {
            var result = new List <IExifValue>();

            if (!EnumUtils.HasFlag(this.allowedParts, part))
            {
                return(result);
            }

            foreach (IExifValue value in this.values)
            {
                if (!HasValue(value))
                {
                    continue;
                }

                if (ExifTags.GetPart(value.Tag) == part)
                {
                    result.Add(value);
                }
            }

            return(result);
        }
Пример #9
0
        private Collection <ExifValue> GetPartValues(Collection <ExifValue> values, ExifParts part)
        {
            var result = new Collection <ExifValue>();

            if (!EnumHelper.HasFlag(_allowedParts, part))
            {
                return(result);
            }

            foreach (var value in values)
            {
                if (!HasValue(value))
                {
                    continue;
                }

                if (ExifTags.GetPart(value.Tag) == part)
                {
                    result.Add(value);
                }
            }

            return(result);
        }
Пример #10
0
 public ExifWriter(ExifParts allowedParts)
 => _allowedParts = allowedParts;
Пример #11
0
            private void ProcessProfiles(ImageMetadata imageMetadata, ExifProfile exifProfile, XmpProfile xmpProfile)
            {
                if (exifProfile != null && exifProfile.Parts != ExifParts.None)
                {
                    foreach (IExifValue entry in exifProfile.Values)
                    {
                        if (!this.Collector.Entries.Exists(t => t.Tag == entry.Tag) && entry.GetValue() != null)
                        {
                            ExifParts entryPart = ExifTags.GetPart(entry.Tag);
                            if (entryPart != ExifParts.None && exifProfile.Parts.HasFlag(entryPart))
                            {
                                this.Collector.AddOrReplace(entry.DeepClone());
                            }
                        }
                    }
                }
                else
                {
                    exifProfile.RemoveValue(ExifTag.SubIFDOffset);
                }

                if (imageMetadata.IptcProfile != null)
                {
                    imageMetadata.IptcProfile.UpdateData();
                    var iptc = new ExifByteArray(ExifTagValue.IPTC, ExifDataType.Byte)
                    {
                        Value = imageMetadata.IptcProfile.Data
                    };

                    this.Collector.Add(iptc);
                }
                else
                {
                    exifProfile.RemoveValue(ExifTag.IPTC);
                }

                if (imageMetadata.IccProfile != null)
                {
                    var icc = new ExifByteArray(ExifTagValue.IccProfile, ExifDataType.Undefined)
                    {
                        Value = imageMetadata.IccProfile.ToByteArray()
                    };

                    this.Collector.Add(icc);
                }
                else
                {
                    exifProfile.RemoveValue(ExifTag.IccProfile);
                }

                if (xmpProfile != null)
                {
                    var xmp = new ExifByteArray(ExifTagValue.XMP, ExifDataType.Byte)
                    {
                        Value = xmpProfile.Data
                    };

                    this.Collector.Add(xmp);
                }
                else
                {
                    exifProfile.RemoveValue(ExifTag.XMP);
                }
            }
Пример #12
0
 private List <IExifValue> GetPartValues(ExifParts part)
 {
     var result = new List <IExifValue>();
Пример #13
0
    public ExifWriter(Collection<ExifValue> values, ExifParts allowedParts, bool bestPrecision)
    {
      _Values = values;
      _AllowedParts = allowedParts;
      _BestPrecision = bestPrecision;

      _IfdIndexes = GetIndexes(ExifParts.IfdTags, _IfdTags);
      _ExifIndexes = GetIndexes(ExifParts.ExifTags, _ExifTags);
      _GPSIndexes = GetIndexes(ExifParts.GPSTags, _GPSTags);
    }
Пример #14
0
    private Collection<int> GetIndexes(ExifParts part, ExifTag[] tags)
    {
      if (((int)_AllowedParts & (int)part) == 0)
        return new Collection<int>();

      Collection<int> result = new Collection<int>();
      for (int i = 0; i < _Values.Count; i++)
      {
        ExifValue value = _Values[i];

        if (!value.HasValue)
          continue;

        int index = Array.IndexOf(tags, value.Tag);
        if (index > -1)
          result.Add(i);
      }

      return result;
    }