Class: Cul::Image::Properties::Bmp
- Defined in:
- lib/cul_image_props/image/properties/types.rb
Constant Summary
Constants inherited from Base
Cul::Image::Properties::Base::BASE_XML
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(srcfile = nil) ⇒ Bmp
constructor
A new instance of Bmp.
Methods inherited from Base
#[], #add_dt_prop, #extent=, #format=, #hex_inspect, #length=, #ord_value, #sampling_unit=, #width=, #x_sampling_freq=, #y_sampling_freq=
Constructor Details
#initialize(srcfile = nil) ⇒ Bmp
Returns a new instance of Bmp.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/cul_image_props/image/properties/types.rb', line 106 def initialize(srcfile=nil) super header_bytes = @src.read(18) unless header_bytes[0...2].unpack('C*') == Cul::Image::Magic::BMP raise "Source file is not a bitmap: #{hex_inspect(header_bytes[0...2])}" end size = header_bytes[-4,4].unpack('V')[0] header_bytes = header_bytes + @src.read(size) dims = header_bytes[0x12...0x1a].unpack('VV') sampling = header_bytes[0x26...0x2e].unpack('VV') self.sampling_unit=3 self.width= dims[0] self.length= dims[1] self.format= MIME[:bmp] self.extent= srcfile.stat.size unless srcfile.nil? self.x_sampling_freq= (sampling[0]) # / 100).ceil self.y_sampling_freq= (sampling[1]) # / 100).ceil end |