Class: PureJPEG::Source::ChunkyPNGSource
- Inherits:
-
Object
- Object
- PureJPEG::Source::ChunkyPNGSource
- Defined in:
- lib/pure_jpeg/source/chunky_png_source.rb
Overview
Pixel source adapter for ChunkyPNG::Image.
Wraps a ChunkyPNG::Image so it can be passed directly to PureJPEG.encode. Requires the chunky_png gem.
Instance Attribute Summary collapse
-
#height ⇒ Integer
readonly
Image height in pixels.
-
#packed_pixels ⇒ Array<Integer>
readonly
Flat row-major array of packed RGBA integers.
-
#width ⇒ Integer
readonly
Image width in pixels.
Instance Method Summary collapse
-
#[](x, y) ⇒ Pixel
Retrieve a pixel at the given coordinate.
-
#initialize(image, background: nil) ⇒ ChunkyPNGSource
constructor
A new instance of ChunkyPNGSource.
Constructor Details
#initialize(image, background: nil) ⇒ ChunkyPNGSource
Returns a new instance of ChunkyPNGSource.
23 24 25 26 27 28 29 30 31 |
# File 'lib/pure_jpeg/source/chunky_png_source.rb', line 23 def initialize(image, background: nil) @width = image.width @height = image.height @packed_pixels = if background.nil? image.pixels else composite_pixels(image.pixels, background) end end |
Instance Attribute Details
#height ⇒ Integer (readonly)
Returns image height in pixels.
18 19 20 |
# File 'lib/pure_jpeg/source/chunky_png_source.rb', line 18 def height @height end |
#packed_pixels ⇒ Array<Integer> (readonly)
Returns flat row-major array of packed RGBA integers.
34 35 36 |
# File 'lib/pure_jpeg/source/chunky_png_source.rb', line 34 def packed_pixels @packed_pixels end |
#width ⇒ Integer (readonly)
Returns image width in pixels.
16 17 18 |
# File 'lib/pure_jpeg/source/chunky_png_source.rb', line 16 def width @width end |