Class: ZPNG::Chunk::IHDR
- Inherits:
-
ZPNG::Chunk
- Object
- ZPNG::Chunk
- ZPNG::Chunk::IHDR
- Defined in:
- lib/zpng/chunk.rb
Constant Summary collapse
- PALETTE_USED =
1
- COLOR_USED =
2
- ALPHA_USED =
4
- COLOR_GRAYSCALE =
Each pixel is a grayscale sample
0
- COLOR_RGB =
Each pixel is an R,G,B triple.
2
- COLOR_INDEXED =
Each pixel is a palette index; a PLTE chunk must appear.
3
- COLOR_GRAY_ALPHA =
Each pixel is a grayscale sample, followed by an alpha sample.
4
- COLOR_RGBA =
Each pixel is an R,G,B triple, followed by an alpha sample.
6
- SAMPLES_PER_COLOR =
{ COLOR_GRAYSCALE => 1, COLOR_RGB => 3, COLOR_INDEXED => 1, COLOR_GRAY_ALPHA => 2, COLOR_RGBA => 4 }
- FORMAT =
'NNC5'
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#compression ⇒ Object
Returns the value of attribute compression.
-
#depth ⇒ Object
Returns the value of attribute depth.
-
#filter ⇒ Object
Returns the value of attribute filter.
-
#height ⇒ Object
Returns the value of attribute height.
-
#interlace ⇒ Object
Returns the value of attribute interlace.
-
#width ⇒ Object
Returns the value of attribute width.
Attributes inherited from ZPNG::Chunk
Instance Method Summary collapse
- #alpha_used? ⇒ Boolean
-
#bpp ⇒ Object
bits per pixel.
- #color_used? ⇒ Boolean
- #export_data ⇒ Object
- #grayscale? ⇒ Boolean
-
#initialize(io) ⇒ IHDR
constructor
A new instance of IHDR.
- #inspect ⇒ Object
- #palette_used? ⇒ Boolean
Methods inherited from ZPNG::Chunk
#crc_ok?, #export, from_stream
Constructor Details
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def color @color end |
#compression ⇒ Object
Returns the value of attribute compression.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def compression @compression end |
#depth ⇒ Object
Returns the value of attribute depth.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def depth @depth end |
#filter ⇒ Object
Returns the value of attribute filter.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def filter @filter end |
#height ⇒ Object
Returns the value of attribute height.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def height @height end |
#interlace ⇒ Object
Returns the value of attribute interlace.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def interlace @interlace end |
#width ⇒ Object
Returns the value of attribute width.
51 52 53 |
# File 'lib/zpng/chunk.rb', line 51 def width @width end |
Instance Method Details
#alpha_used? ⇒ Boolean
99 100 101 |
# File 'lib/zpng/chunk.rb', line 99 def alpha_used? (@color & ALPHA_USED) != 0 end |
#bpp ⇒ Object
bits per pixel
83 84 85 |
# File 'lib/zpng/chunk.rb', line 83 def bpp SAMPLES_PER_COLOR[@color] * depth end |
#color_used? ⇒ Boolean
87 88 89 |
# File 'lib/zpng/chunk.rb', line 87 def color_used? (@color & COLOR_USED) != 0 end |
#export_data ⇒ Object
78 79 80 |
# File 'lib/zpng/chunk.rb', line 78 def export_data [@width, @height, @depth, @color, @compression, @filter, @interlace].pack(FORMAT) end |
#grayscale? ⇒ Boolean
91 92 93 |
# File 'lib/zpng/chunk.rb', line 91 def grayscale? !color_used? end |
#inspect ⇒ Object
103 104 105 106 107 108 |
# File 'lib/zpng/chunk.rb', line 103 def inspect super.sub(/ *>$/,'') + ", " + (instance_variables-[:@type, :@crc, :@data, :@size]). map{ |var| "#{var.to_s.tr('@','')}=#{instance_variable_get(var)}" }. join(", ") + ">" end |
#palette_used? ⇒ Boolean
95 96 97 |
# File 'lib/zpng/chunk.rb', line 95 def palette_used? (@color & PALETTE_USED) != 0 end |