Class: ZPNG::BMP::BmpHdrPseudoChunk

Inherits:
Chunk::IHDR show all
Defined in:
lib/zpng/bmp/reader.rb

Constant Summary

Constants inherited from Chunk::IHDR

Chunk::IHDR::ALLOWED_DEPTHS, Chunk::IHDR::ALPHA_USED, Chunk::IHDR::COLOR_USED, Chunk::IHDR::FORMAT, Chunk::IHDR::PALETTE_USED, Chunk::IHDR::SAMPLES_PER_COLOR, Chunk::IHDR::SIZE

Constants inherited from Chunk

Chunk::KNOWN_TYPES, Chunk::VALID_SIZE_RANGE

Instance Attribute Summary

Attributes inherited from Chunk::IHDR

#color, #compression, #depth, #filter, #height, #interlace, #width

Attributes inherited from Chunk

#crc, #data, #idx, #offset, #size, #type

Instance Method Summary collapse

Methods inherited from Chunk::IHDR

#alpha_used?, #bpp, #color_used?, #export_data, #grayscale?, #palette_used?

Methods inherited from Chunk

#check, #crc_ok?, #export, #export_data, #fix_crc!, from_stream, #valid?

Methods included from DeepCopyable

#deep_copy

Constructor Details

#initialize(bmp_hdr) ⇒ BmpHdrPseudoChunk

Returns a new instance of BmpHdrPseudoChunk.



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/zpng/bmp/reader.rb', line 35

def initialize bmp_hdr
  @bmp_hdr = bmp_hdr
  h = {
    :width   => bmp_hdr.biWidth,
    :height  => bmp_hdr.biHeight.abs,
    :type    => 'BITMAPINFOHEADER',
    :crc     => :no_crc               # for CLI
  }
  if bmp_hdr.biBitCount == 8
    h[:color] = COLOR_INDEXED
    h[:depth] = 8
  else
    h[:bpp] = bmp_hdr.biBitCount
  end
  super(h)
  self.data = bmp_hdr.pack
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(mname, *args) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/zpng/bmp/reader.rb', line 55

def method_missing mname, *args
  if @bmp_hdr.respond_to?(mname)
    @bmp_hdr.send(mname,*args)
  else
    super
  end
end

Instance Method Details

#inspect(*args) ⇒ Object



52
53
54
# File 'lib/zpng/bmp/reader.rb', line 52

def inspect *args
  @bmp_hdr.inspect
end