Class: ZIMG::JPEG::Frame
- Inherits:
-
Object
- Object
- ZIMG::JPEG::Frame
- Defined in:
- lib/zimg/jpeg/decoder.rb
Instance Attribute Summary collapse
-
#components ⇒ Object
Returns the value of attribute components.
-
#height ⇒ Object
Returns the value of attribute height.
-
#max_h ⇒ Object
readonly
Returns the value of attribute max_h.
-
#max_v ⇒ Object
readonly
Returns the value of attribute max_v.
-
#mcus_per_column ⇒ Object
readonly
Returns the value of attribute mcus_per_column.
-
#mcus_per_line ⇒ Object
readonly
Returns the value of attribute mcus_per_line.
-
#progressive ⇒ Object
Returns the value of attribute progressive.
-
#width ⇒ Object
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(sof, qtables) ⇒ Frame
constructor
A new instance of Frame.
Constructor Details
#initialize(sof, qtables) ⇒ Frame
Returns a new instance of Frame.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/zimg/jpeg/decoder.rb', line 9 def initialize(sof, qtables) @width = sof.width @height = sof.height @progressive = sof.progressive? @components = sof.components # According to the JPEG standard, the sampling factor must be between 1 and 4 # See https://github.com/libjpeg-turbo/libjpeg-turbo/blob/9abeff46d87bd201a952e276f3e4339556a403a3/libjpeg.txt#L1138-L1146 @max_h = components.map(&:h).max @max_v = components.map(&:v).max @mcus_per_line = (width / 8.0 / max_h).ceil @mcus_per_column = (height / 8.0 / max_v).ceil components.each do |c| c.prepare(self, qtables) end end |
Instance Attribute Details
#components ⇒ Object
Returns the value of attribute components.
6 7 8 |
# File 'lib/zimg/jpeg/decoder.rb', line 6 def components @components end |
#height ⇒ Object
Returns the value of attribute height.
6 7 8 |
# File 'lib/zimg/jpeg/decoder.rb', line 6 def height @height end |
#max_h ⇒ Object (readonly)
Returns the value of attribute max_h.
7 8 9 |
# File 'lib/zimg/jpeg/decoder.rb', line 7 def max_h @max_h end |
#max_v ⇒ Object (readonly)
Returns the value of attribute max_v.
7 8 9 |
# File 'lib/zimg/jpeg/decoder.rb', line 7 def max_v @max_v end |
#mcus_per_column ⇒ Object (readonly)
Returns the value of attribute mcus_per_column.
7 8 9 |
# File 'lib/zimg/jpeg/decoder.rb', line 7 def mcus_per_column @mcus_per_column end |
#mcus_per_line ⇒ Object (readonly)
Returns the value of attribute mcus_per_line.
7 8 9 |
# File 'lib/zimg/jpeg/decoder.rb', line 7 def mcus_per_line @mcus_per_line end |
#progressive ⇒ Object
Returns the value of attribute progressive.
6 7 8 |
# File 'lib/zimg/jpeg/decoder.rb', line 6 def progressive @progressive end |
#width ⇒ Object
Returns the value of attribute width.
6 7 8 |
# File 'lib/zimg/jpeg/decoder.rb', line 6 def width @width end |