class Exif::Sony

Public Class Methods

new(fin, tiff_origin, dataPos, byteOrder_module) click to toggle source
# 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

Public Instance Methods

scan_IFD() { |obj| ... } click to toggle source
# 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

Private Instance Methods

fin_read_n(n) click to toggle source
# File lib/exifparser/makernote/sony.rb, line 787
def fin_read_n(n)
  @fin.read(n)
end