Class: Exif::Nikon

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

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Nikon.



210
211
212
213
214
215
216
# File 'lib/exifparser/makernote/nikon.rb', line 210

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



218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/exifparser/makernote/nikon.rb', line 218

def scan_IFD
  #
  # Nikon MakerNote starts from 8 byte from the origin.
  #
  @fin.pos = @dataPos + 8
  #
  # get the number of tags
  #
  num_dirs = decode_ushort(fin_read_n(2))

  #
  # now scan them
  #
  1.upto(num_dirs) {
    curpos_tag = @fin.pos
    tag = parseTagID(fin_read_n(2))
    tagclass = Tag.find(tag.hex, Tag::NikonIFDTable)
    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