Example #1
0
        private ExifValue CreateValue(ExifTagValue tag, ExifDataType dataType, uint numberOfComponents)
        {
            if (!_reader.CanRead(numberOfComponents))
            {
                return(null);
            }

            var exifValue = ExifValues.Create(tag);

            if (exifValue == null)
            {
                exifValue = ExifValues.Create(tag, dataType, numberOfComponents);
            }

            if (exifValue == null)
            {
                return(null);
            }

            var value = ReadValue(dataType, numberOfComponents);

            if (!exifValue.SetValue(value))
            {
                return(null);
            }

            return(exifValue);
        }
Example #2
0
        private static IExifValue GetOffsetValue(Collection <IExifValue> ifdValues, Collection <IExifValue> values, ExifTag offsetTag)
        {
            var index = -1;

            for (var i = 0; i < ifdValues.Count; i++)
            {
                if (ifdValues[i].Tag == offsetTag)
                {
                    index = i;
                }
            }

            if (values.Count > 0)
            {
                if (index != -1)
                {
                    return(ifdValues[index]);
                }

                var result = ExifValues.Create(offsetTag);
                ifdValues.Add(result);

                return(result);
            }
            else if (index != -1)
            {
                ifdValues.RemoveAt(index);
            }

            return(null);
        }
Example #3
0
        /// <summary>
        /// Sets the value of the specified tag.
        /// </summary>
        /// <param name="tag">The tag of the exif value.</param>
        /// <param name="value">The value.</param>
        public void SetValue(ExifTag tag, object value)
        {
            foreach (var exifValue in Values)
            {
                if (exifValue.Tag == tag)
                {
                    exifValue.Value = value;
                    return;
                }
            }

            var newExifValue = ExifValues.Create(tag, value);

            _values.Add(newExifValue);
        }
Example #4
0
        /// <summary>
        /// Sets the value of the specified tag.
        /// </summary>
        /// <param name="tag">The tag of the exif value.</param>
        /// <param name="value">The value.</param>
        /// <typeparam name="TValueType">The data type of the tag.</typeparam>
        public void SetValue <TValueType>(ExifTag <TValueType> tag, TValueType value)
        {
            foreach (var exifValue in Values)
            {
                if (exifValue.Tag == tag)
                {
                    exifValue.SetValue(value);
                    return;
                }
            }

            var newExifValue = ExifValues.Create(tag);

            if (newExifValue == null)
            {
                throw new NotSupportedException();
            }

            newExifValue.SetValue(value);
            _values.Add(newExifValue);
        }
Example #5
0
        /// <summary>
        /// Sets the value of the specified tag.
        /// </summary>
        /// <param name="tag">The tag of the exif value.</param>
        /// <param name="value">The value.</param>
        /// <typeparam name="TValueType">The data type of the tag.</typeparam>
        public void SetValue <TValueType>(ExifTag <TValueType> tag, TValueType value)
        {
            Throw.IfNull(nameof(value), value);

            InitializeValues();
            foreach (var exifValue in _data.Values)
            {
                if (exifValue.Tag == tag)
                {
                    exifValue.SetValue(value);
                    return;
                }
            }

            var newExifValue = ExifValues.Create(tag);

            if (newExifValue == null)
            {
                throw new NotSupportedException();
            }

            newExifValue.SetValue(value);
            _data.Values.Add(newExifValue);
        }