Class: ImageRuby::BmpCDecoder

Inherits:
Decoder
  • Object
show all
Defined in:
lib/imageruby-bmp-c.rb

Instance Method Summary collapse

Instance Method Details

#decode(data, image_class) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/imageruby-bmp-c.rb', line 25

def decode(data, image_class)
  if data[0..1] != "BM"
    raise UnableToDecodeException
  end

  dib_header = data[14..54]

  width = dib_header[4..7].unpack("L").first
  height = dib_header[8..11].unpack("L").first

  image = image_class.new(width,height)
  ImageRubyBmpC.decode_bitmap(data, image)
  image
end