def process_bmp(data, filename)       #:nodoc:
      type     = 'bmp'

      # Check that the file is big enough to be a bitmap.
      raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36

      # Read the bitmap width and height. Verify the sizes.
      width, height = data.unpack("x18 V2")
      raise "#{filename}: largest image width #{width} supported is 65k." if width > 0xFFFF
      raise "#{filename}: largest image height supported is 65k." if height > 0xFFFF

      # Read the bitmap planes and bpp data. Verify them.
      planes, bitcount = data.unpack("x26 v2")
      raise "#{filename} isn't a 24bit true color bitmap." unless bitcount == 24
      raise "#{filename}: only 1 plane supported in bitmap image." unless planes == 1

      # Read the bitmap compression. Verify compression.
      compression = data.unpack("x30 V")[0]
      raise "#{filename}: compression not supported in bitmap image." unless compression == 0
      [type, width, height]
    end
def process_bmp(data, filename)       #:nodoc:
      type     = 'bmp'

      # Check that the file is big enough to be a bitmap.
      raise "#{filename} doesn't contain enough data." if data.bytesize <= 0x36

      # Read the bitmap width and height. Verify the sizes.
      width, height = data.unpack("x18 V2")
      raise "#{filename}: largest image width #{width} supported is 65k." if width > 0xFFFF
      raise "#{filename}: largest image height supported is 65k." if height > 0xFFFF

      # Read the bitmap planes and bpp data. Verify them.
      planes, bitcount = data.unpack("x26 v2")
      raise "#{filename} isn't a 24bit true color bitmap." unless bitcount == 24
      raise "#{filename}: only 1 plane supported in bitmap image." unless planes == 1

      # Read the bitmap compression. Verify compression.
      compression = data.unpack("x30 V")[0]
      raise "#{filename}: compression not supported in bitmap image." unless compression == 0
      [type, width, height]
    end
Extract width and height information from a BMP file.