Class: FastImageParsing::Bmp

Inherits:
ImageBase show all
Defined in:
lib/fastimage/fastimage_parsing/bmp.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from ImageBase

#animated?, #initialize

Constructor Details

This class inherits a constructor from FastImageParsing::ImageBase

Instance Method Details

#dimensionsObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fastimage/fastimage_parsing/bmp.rb', line 3

def dimensions
  d = @stream.read(32)[14..28]
  header = d.unpack("C")[0]

  result = if header == 12
             d[4..8].unpack('SS')
           else
             d[4..-1].unpack('l<l<')
           end

  # ImageHeight is expressed in pixels. The absolute value is necessary because ImageHeight can be negative
  [result.first, result.last.abs]
end