Пример #1
0
        internal static uint GetNumberOfComponents(IExifValue exifValue)
        {
            object value = exifValue.GetValue();

            if (ExifUcs2StringHelpers.IsUcs2Tag((ExifTagValue)(ushort)exifValue.Tag))
            {
                return((uint)ExifUcs2StringHelpers.Ucs2Encoding.GetByteCount((string)value));
            }

            if (value is EncodedString encodedString)
            {
                return(ExifEncodedStringHelpers.GetDataLength(encodedString));
            }

            if (exifValue.DataType == ExifDataType.Ascii)
            {
                return((uint)ExifConstants.DefaultEncoding.GetByteCount((string)value) + 1);
            }

            if (value is Array arrayValue)
            {
                return((uint)arrayValue.Length);
            }

            return(1);
        }
Пример #2
0
        public override bool TrySetValue(object value)
        {
            if (base.TrySetValue(value))
            {
                return(true);
            }

            if (value is string stringValue)
            {
                this.Value = new EncodedString(stringValue);
                return(true);
            }
            else if (value is byte[] buffer)
            {
                if (ExifEncodedStringHelpers.TryParse(buffer, out EncodedString encodedString))
                {
                    this.Value = encodedString;
                    return(true);
                }
            }

            return(false);
        }