Class: PNG::IHDR
Constant Summary collapse
- SUPPORTED_COLOR_TYPES =
[2,3,6]
Instance Attribute Summary collapse
-
#color_type ⇒ Object
Returns the value of attribute color_type.
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#height ⇒ Object
Returns the value of attribute height.
-
#width ⇒ Object
Returns the value of attribute width.
Class Method Summary collapse
-
.new_from_raw(data) ⇒ Object
attr_accessor :compression_method, :filter_method, :interlace_method.
Instance Method Summary collapse
- #chunk_name ⇒ Object
- #encode ⇒ Object
-
#initialize(width, height, depth = 8, color_type = 2, compression = 0, filter = 0, interlace = 0) ⇒ IHDR
constructor
A new instance of IHDR.
- #to_a ⇒ Object
Methods inherited from Chunk
Constructor Details
#initialize(width, height, depth = 8, color_type = 2, compression = 0, filter = 0, interlace = 0) ⇒ IHDR
Returns a new instance of IHDR.
13 14 15 16 17 18 19 20 |
# File 'lib/spittle/png/ihdr.rb', line 13 def initialize( width, height, depth=8, color_type=2, compression=0, filter=0, interlace=0 ) raise "for now, spittle only supports non-interlaced images" unless interlace == 0 raise "for now, spittle only supports images with a bit depth of 8" unless depth == 8 unless SUPPORTED_COLOR_TYPES.include? color_type raise "for now, spittle only supports color types #{SUPPORTED_COLOR_TYPES.JOIN(',')} color type was #{color_type}" end @width, @height, @depth, @color_type = width, height, depth, color_type end |
Instance Attribute Details
#color_type ⇒ Object
Returns the value of attribute color_type.
4 5 6 |
# File 'lib/spittle/png/ihdr.rb', line 4 def color_type @color_type end |
#depth ⇒ Object
Returns the value of attribute depth.
4 5 6 |
# File 'lib/spittle/png/ihdr.rb', line 4 def depth @depth end |
#height ⇒ Object
Returns the value of attribute height.
4 5 6 |
# File 'lib/spittle/png/ihdr.rb', line 4 def height @height end |
#width ⇒ Object
Returns the value of attribute width.
4 5 6 |
# File 'lib/spittle/png/ihdr.rb', line 4 def width @width end |
Class Method Details
.new_from_raw(data) ⇒ Object
attr_accessor :compression_method, :filter_method, :interlace_method
7 8 9 10 11 |
# File 'lib/spittle/png/ihdr.rb', line 7 def self.new_from_raw( data ) raw = data.unpack("N2C5") new( *raw[0..6] ) end |
Instance Method Details
#chunk_name ⇒ Object
30 31 32 |
# File 'lib/spittle/png/ihdr.rb', line 30 def chunk_name "IHDR" end |
#encode ⇒ Object
22 23 24 |
# File 'lib/spittle/png/ihdr.rb', line 22 def encode to_a.pack("N2C5") end |
#to_a ⇒ Object
26 27 28 |
# File 'lib/spittle/png/ihdr.rb', line 26 def to_a [@width, @height, @depth, @color_type, 0, 0, 0] end |