Class: Exif::Sony

Inherits:
Object
  • Object
show all
Defined in:
lib/exifparser/makernote/sony.rb

Instance Method Summary collapse

Constructor Details

#initialize(fin, tiff_origin, dataPos, byteOrder_module) ⇒ Sony

Returns a new instance of Sony.



733
734
735
736
737
738
739
# File 'lib/exifparser/makernote/sony.rb', line 733

def initialize(fin, tiff_origin, dataPos, byteOrder_module)
  @fin = fin
  @tiffHeader0 = tiff_origin
  @dataPos = dataPos
  @byteOrder_module = byteOrder_module
  self.extend @byteOrder_module
end

Instance Method Details

#scan_IFDObject



741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
# File 'lib/exifparser/makernote/sony.rb', line 741

def scan_IFD
  #
  # Sony MakerNote starts from 12 byte from the origin
  #

  @fin.pos = @dataPos + 12

  #
  # get the number of tags
  #
  numDirs = decode_ushort(fin_read_n(2))

  #
  # now scan them
  #
  1.upto(numDirs) {
    curpos_tag = @fin.pos
    tag = parseTagID(fin_read_n(2))
    tagclass = Tag.find(tag.hex, Tag::SonyIFDTable)
    unit, formatter = Tag::Format::Unit[decode_ushort(fin_read_n(2))]
    count = decode_ulong(fin_read_n(4))
    tagdata = fin_read_n(4)

    obj = tagclass.new(tag, "MakerNote", count)
    obj.extend formatter, @byteOrder_module
    obj.pos = curpos_tag
    if unit * count > 4
      curpos = @fin.pos
      begin
        @fin.pos = @tiffHeader0 + decode_ulong(tagdata)
        obj.dataPos = @fin.pos
        obj.data = fin_read_n(unit*count)
      ensure
        @fin.pos = curpos
      end
    else
      obj.dataPos = @fin.pos - 4
      obj.data = tagdata
    end
    obj.processData
    yield obj
  }
end