コード例 #1
0
        private static IExifValue CreateNumberValue(ExifTag tag, object value)
        {
            switch (tag)
            {
            case ExifTag.StripOffsets:
            case ExifTag.TileByteCounts:
            case ExifTag.ImageLayer:
                switch (value)
                {
                case null:
                    return(new ExifShortArray(tag));

                case ushort[] ushortValue:
                    return(ExifShortArray.Create(tag, ushortValue));

                case uint[] ulongValue:
                    return(ExifLongArray.Create(tag, ulongValue));

                default:
                    throw new NotSupportedException();
                }

            case ExifTag.ImageWidth:
            case ExifTag.ImageLength:
            case ExifTag.TileWidth:
            case ExifTag.TileLength:
            case ExifTag.BadFaxLines:
            case ExifTag.ConsecutiveBadFaxLines:
            case ExifTag.PixelXDimension:
            case ExifTag.PixelYDimension:
                switch (value)
                {
                case null:
                    return(new ExifShort(tag));

                case ushort ushortValue:
                    return(ExifShort.Create(tag, ushortValue));

                case short shortValue:
                    return(ExifShort.Create(tag, (ushort)shortValue));

                case uint ulongValue:
                    return(ExifLong.Create(tag, ulongValue));

                case int longValue:
                    return(ExifLong.Create(tag, (uint)longValue));

                default:
                    throw new NotSupportedException();
                }

            default:
                return(null);
            }
        }
コード例 #2
-1
        private IExifValue CreateValue(ExifTag tag, ExifDataType dataType, uint numberOfComponents)
        {
            switch (dataType)
            {
            case ExifDataType.Byte:
            case ExifDataType.Undefined:
                if (numberOfComponents == 1)
                {
                    return(ExifByte.Create(tag, dataType, ReadByte()));
                }
                else
                {
                    return(ExifByteArray.Create(tag, dataType, ReadArray(numberOfComponents, ReadByte)));
                }

            case ExifDataType.Double:
                if (numberOfComponents == 1)
                {
                    return(ExifDouble.Create(tag, ReadDouble()));
                }
                else
                {
                    return(ExifDoubleArray.Create(tag, ReadArray(numberOfComponents, ReadDouble)));
                }

            case ExifDataType.Float:

                if (numberOfComponents == 1)
                {
                    return(ExifFloat.Create(tag, ReadFloat()));
                }
                else
                {
                    return(ExifFloatArray.Create(tag, ReadArray(numberOfComponents, ReadFloat)));
                }

            case ExifDataType.Long:
                if (numberOfComponents == 1)
                {
                    return(ExifLong.Create(tag, ReadLong()));
                }
                else
                {
                    return(ExifLongArray.Create(tag, ReadArray(numberOfComponents, ReadLong)));
                }

            case ExifDataType.Rational:
                if (numberOfComponents == 1)
                {
                    return(ExifRational.Create(tag, ReadRational()));
                }
                else
                {
                    return(ExifRationalArray.Create(tag, ReadArray(numberOfComponents, ReadRational)));
                }

            case ExifDataType.Short:
                if (numberOfComponents == 1)
                {
                    return(ExifShort.Create(tag, ReadShort()));
                }
                else
                {
                    return(ExifShortArray.Create(tag, ReadArray(numberOfComponents, ReadShort)));
                }

            case ExifDataType.SignedByte:
                if (numberOfComponents == 1)
                {
                    return(ExifSignedByte.Create(tag, ReadSignedByte()));
                }
                else
                {
                    return(ExifSignedByteArray.Create(tag, ReadArray(numberOfComponents, ReadSignedByte)));
                }

            case ExifDataType.SignedLong:
                if (numberOfComponents == 1)
                {
                    return(ExifSignedLong.Create(tag, ReadSignedLong()));
                }
                else
                {
                    return(ExifSignedLongArray.Create(tag, ReadArray(numberOfComponents, ReadSignedLong)));
                }

            case ExifDataType.SignedRational:
                if (numberOfComponents == 1)
                {
                    return(ExifSignedRational.Create(tag, ReadSignedRational()));
                }
                else
                {
                    return(ExifSignedRationalArray.Create(tag, ReadArray(numberOfComponents, ReadSignedRational)));
                }

            case ExifDataType.SignedShort:
                if (numberOfComponents == 1)
                {
                    return(ExifSignedShort.Create(tag, ReadSignedShort()));
                }
                else
                {
                    return(ExifSignedShortArray.Create(tag, ReadArray(numberOfComponents, ReadSignedShort)));
                }

            case ExifDataType.String:
                return(ExifString.Create(tag, ReadString(numberOfComponents)));

            default:
                throw new NotSupportedException();
            }
        }