Exemplo n.º 1
0
        public static IfdBlock parse(BinaryReader reader)
        {
            var result = new IfdBlock();

            result.rawtag = reader.ReadUInt16();
            IfdTag tag;

            result.tag = (TagMap.TryGetValue(result.rawtag, out tag)) ? (IfdTag?)tag : null;

            result.rawtype = reader.ReadUInt16();
            result.type    = IfdTypes[result.rawtype];

            var length = reader.ReadUInt32();

            result.length     = length;
            result.nextOffset = ((uint)reader.BaseStream.Position) + 4;
            var datalength = length * result.type.BytesLength;

            if (datalength > 4)
            {
                reader.BaseStream.Seek(reader.ReadUInt32(), SeekOrigin.Begin);
            }

            result.rawdata = reader.ReadBytes((int)datalength);
            if (datalength < 4)
            {
                reader.ReadBytes(4 - (int)datalength);
            }
            return(result);
        }
Exemplo n.º 2
0
        void ParseIfd(BinaryReader reader)
        {
            var blocksnumber = reader.ReadUInt16();

            if (blocksnumber > 512)
            {
                throw new ArgumentException("Too many items in ifd");
            }
            while (blocksnumber-- > 0)
            {
                var block = IfdBlock.parse(reader);
                _ifdBlocks.Add(block);
                ParseIfdBlock(block, reader);
                block.moveNext(reader);
            }
        }
Exemplo n.º 3
0
        protected override void ParseIfdBlock(IfdBlock block, BinaryReader reader)
        {
            PanasoncIfdTag tag;
            if (!TagMap.TryGetValue(block.rawtag, out tag))
            {
                base.ParseIfdBlock(block, reader);
                return;
            }

            switch (tag)
            {
                case PanasoncIfdTag.CropLeft:
                    CropLeft = (int) block.GetUInt32();
                    CropRight += CropLeft;
                    break;
                case PanasoncIfdTag.CropTop:
                    CropTop = (int) block.GetUInt32();
                    CropBottom += CropTop;
                    break;
                case PanasoncIfdTag.CropWidth:
                    CropRight += (int) block.GetUInt32();
                    break;
                case PanasoncIfdTag.CropHeight:
                    CropBottom += (int) block.GetUInt32();
                    break;
                case PanasoncIfdTag.Filters:
                    Filters = (int) block.GetUInt32();
                    break;
                case PanasoncIfdTag.Iso:
                    Iso = (int) block.GetUInt32();
                    break;
                case PanasoncIfdTag.Black:
                    Black[block.rawtag - 28] = block.GetUInt16();
                    Black[3] = Black[1];
                    break;
                case PanasoncIfdTag.CamMul:
                    if (CamMul == null) CamMul = new float[3];
                    CamMul[block.rawtag - 36] = block.GetUInt16();
                    break;
                case PanasoncIfdTag.Thumb:
                    Thumbnail = block.rawdata;
                    break;
                case PanasoncIfdTag.RawOffset:
                    RawOffset = (int) block.GetUInt32();
                    break;
            }
        }
Exemplo n.º 4
0
 protected virtual void ParseIfdBlock(IfdBlock block, BinaryReader reader)
 {
     switch (block.tag)
     {
         case IfdTag.ImageWidth:
             ImageWidth = block.GetUInt16();
             break;
         case IfdTag.ImageLength:
             ImageHeight = block.GetUInt16();
             break;
         case IfdTag.Make:
             Maker = block.GetString();
             break;
         case IfdTag.Model:
             Model = block.GetString();
             break;
         case IfdTag.StripOffsets:
             StripOffset = (int) block.GetUInt32();
             break;
         case IfdTag.Orientation:
             Orientation = (int) block.GetUInt32();
             break;
         case IfdTag.RowsPerStrip:
             StripByteCounts = (int) block.GetUInt32();
             break;
         case IfdTag.ExifIFD:
             reader.BaseStream.Seek(block.GetUInt32(), SeekOrigin.Begin);
             ParseIfd(reader);
             break;
         case IfdTag.ExposureTime:
             Shutter = block.GetFraction();
             break;
         case IfdTag.FNumber:
             Aperture = block.GetFraction();
             break;
         case IfdTag.ExposureProgram:
             ExposureProgram = (int) block.GetUInt32();
             break;
         case IfdTag.ExifVersion:
             ExifVersion = block.GetString();
             break;
         case IfdTag.DateTimeOriginal:
             DateTimeOriginal = block.GetString();
             break;
         case IfdTag.DateTimeDigitized:
             DateTimeDigitized = block.GetString();
             break;
         case IfdTag.ExposureBiasValue:
             ExposureBiasValue = block.GetFraction();
             break;
         case IfdTag.MaxApertureValue:
             MaxApertureValue = block.GetFraction();
             break;
         case IfdTag.MeteringMode:
             MeteringMode = (int) block.GetUInt32();
             break;
         case IfdTag.Flash:
             Flash = (int) block.GetUInt32();
             break;
         case IfdTag.FocalLength:
             FocalLength = block.GetFraction();
             break;
         case IfdTag.SubsecTimeOriginal:
             SubsecTimeOriginal = block.GetString();
             break;
         case IfdTag.SubsecTimeDigitized:
             SubsecTimeDigitized = block.GetString();
             break;
         case IfdTag.FileSource:
             FileSource = (int) block.GetUInt32();
             break;
     }
 }
Exemplo n.º 5
0
        protected virtual void ParseIfdBlock(IfdBlock block, BinaryReader reader)
        {
            switch (block.tag)
            {
            case IfdTag.ImageWidth:
                ImageWidth    = block.GetUInt16();
                block.variant = ImageWidth;
                break;

            case IfdTag.ImageLength:
                ImageHeight   = block.GetUInt16();
                block.variant = ImageHeight;
                break;

            case IfdTag.Make:
                Maker         = block.GetString();
                block.variant = Maker;
                break;

            case IfdTag.Model:
                Model         = block.GetString();
                block.variant = Model;
                break;

            case IfdTag.StripOffsets:
                StripOffset   = (int)block.GetUInt32();
                block.variant = StripOffset;
                break;

            case IfdTag.Orientation:
                Orientation   = (int)block.GetUInt32();
                block.variant = Orientation;
                break;

            case IfdTag.RowsPerStrip:
                StripByteCounts = (int)block.GetUInt32();
                block.variant   = StripByteCounts;
                break;

            case IfdTag.ExifIFD:
                reader.BaseStream.Seek(block.GetUInt32(), SeekOrigin.Begin);
                ParseIfd(reader);
                break;

            case IfdTag.ExposureTime:
                Shutter       = block.GetFraction();
                block.variant = Shutter.ToFloat();
                break;

            case IfdTag.FNumber:
                Aperture      = block.GetFraction();
                block.variant = Aperture.ToFloat();
                break;

            case IfdTag.ExposureProgram:
                ExposureProgram = (int)block.GetUInt32();
                block.variant   = ExposureProgram;
                break;

            case IfdTag.ExifVersion:
                ExifVersion   = block.GetString();
                block.variant = ExifVersion;
                break;

            case IfdTag.DateTimeOriginal:
                DateTimeOriginal = block.GetString();
                block.variant    = DateTimeOriginal;
                break;

            case IfdTag.DateTimeDigitized:
                DateTimeDigitized = block.GetString();
                block.variant     = DateTimeDigitized;
                break;

            case IfdTag.ExposureBiasValue:
                ExposureBiasValue = block.GetFraction();
                block.variant     = ExposureBiasValue.ToFloat();
                break;

            case IfdTag.MaxApertureValue:
                MaxApertureValue = block.GetFraction();
                block.variant    = MaxApertureValue.ToFloat();
                break;

            case IfdTag.MeteringMode:
                MeteringMode  = (int)block.GetUInt32();
                block.variant = MeteringMode;
                break;

            case IfdTag.Flash:
                Flash         = (int)block.GetUInt32();
                block.variant = Flash;
                break;

            case IfdTag.FocalLength:
                FocalLength   = block.GetFraction();
                block.variant = FocalLength.ToFloat();
                break;

            case IfdTag.SubsecTimeOriginal:
                SubsecTimeOriginal = block.GetString();
                block.variant      = SubsecTimeOriginal;
                break;

            case IfdTag.SubsecTimeDigitized:
                SubsecTimeDigitized = block.GetString();
                block.variant       = SubsecTimeDigitized;
                break;

            case IfdTag.FileSource:
                FileSource    = (int)block.GetUInt32();
                block.variant = FileSource;
                break;

            default:
                if (block.length <= 4)
                {
                    block.variant = block.GetUInt32();
                }
                else
                {
                    block.variant = (block.type == IfdType.UInt32Fraction) ? block.GetFraction().ToString() : string.Join(", ", block.rawdata);
                }
                break;
            }
        }
Exemplo n.º 6
0
        protected virtual void ParseIfdBlock(IfdBlock block, BinaryReader reader)
        {
            switch (block.tag)
            {
            case IfdTag.ImageWidth:
                ImageWidth = block.GetUInt16();
                break;

            case IfdTag.ImageLength:
                ImageHeight = block.GetUInt16();
                break;

            case IfdTag.Make:
                Maker = block.GetString();
                break;

            case IfdTag.Model:
                Model = block.GetString();
                break;

            case IfdTag.StripOffsets:
                StripOffset = (int)block.GetUInt32();
                break;

            case IfdTag.Orientation:
                Orientation = (int)block.GetUInt32();
                break;

            case IfdTag.RowsPerStrip:
                StripByteCounts = (int)block.GetUInt32();
                break;

            case IfdTag.ExifIFD:
                reader.BaseStream.Seek(block.GetUInt32(), SeekOrigin.Begin);
                ParseIfd(reader);
                break;

            case IfdTag.ExposureTime:
                Shutter = block.GetFraction();
                break;

            case IfdTag.FNumber:
                Aperture = block.GetFraction();
                break;

            case IfdTag.ExposureProgram:
                ExposureProgram = (int)block.GetUInt32();
                break;

            case IfdTag.ExifVersion:
                ExifVersion = block.GetString();
                break;

            case IfdTag.DateTimeOriginal:
                DateTimeOriginal = block.GetString();
                break;

            case IfdTag.DateTimeDigitized:
                DateTimeDigitized = block.GetString();
                break;

            case IfdTag.ExposureBiasValue:
                ExposureBiasValue = block.GetFraction();
                break;

            case IfdTag.MaxApertureValue:
                MaxApertureValue = block.GetFraction();
                break;

            case IfdTag.MeteringMode:
                MeteringMode = (int)block.GetUInt32();
                break;

            case IfdTag.Flash:
                Flash = (int)block.GetUInt32();
                break;

            case IfdTag.FocalLength:
                FocalLength = block.GetFraction();
                break;

            case IfdTag.SubsecTimeOriginal:
                SubsecTimeOriginal = block.GetString();
                break;

            case IfdTag.SubsecTimeDigitized:
                SubsecTimeDigitized = block.GetString();
                break;

            case IfdTag.FileSource:
                FileSource = (int)block.GetUInt32();
                break;
            }
        }
Exemplo n.º 7
0
        public static IfdBlock parse(BinaryReader reader)
        {
            var result = new IfdBlock();
            result.rawtag = reader.ReadUInt16();
            IfdTag tag;
            result.tag = (TagMap.TryGetValue(result.rawtag, out tag)) ? (IfdTag?) tag : null;

            result.rawtype = reader.ReadUInt16();
            result.type = IfdTypes[result.rawtype];

            var length = reader.ReadUInt32();
            result.length = length;
            result.nextOffset = ((uint) reader.BaseStream.Position) + 4;
            var datalength = length*result.type.BytesLength;
            if (datalength > 4)
                reader.BaseStream.Seek(reader.ReadUInt32(), SeekOrigin.Begin);

            result.rawdata = reader.ReadBytes((int) datalength);
            if (datalength < 4) reader.ReadBytes(4 - (int) datalength);
            return result;
        }