Module: ChunkyPNG::Canvas::StreamExporting
- Included in:
- ChunkyPNG::Canvas
- Defined in:
- lib/chunky_png/canvas/stream_exporting.rb
Overview
Methods to save load a canvas from to stream, encoded in RGB, RGBA, BGR or ABGR format.
Instance Method Summary collapse
-
#to_abgr_stream ⇒ String
Creates an ABGR-formatted pixelstream with the pixel data from this canvas.
-
#to_rgb_stream ⇒ String
Creates an RGB-formatted pixelstream with the pixel data from this canvas.
-
#to_rgba_stream ⇒ String
Creates an RGB-formatted pixelstream with the pixel data from this canvas.
Instance Method Details
#to_abgr_stream ⇒ String
Creates an ABGR-formatted pixelstream with the pixel data from this canvas.
Note that this format is fast but bloated, because no compression is used and the internal representation is left intact. To reconstruct the canvas, the width and height should be known.
36 37 38 |
# File 'lib/chunky_png/canvas/stream_exporting.rb', line 36 def to_abgr_stream pixels.pack('V*') end |
#to_rgb_stream ⇒ String
Creates an RGB-formatted pixelstream with the pixel data from this canvas.
Note that this format is fast but bloated, because no compression is used and the internal representation is almost left intact. To reconstruct the canvas, the width and height should be known.
25 26 27 |
# File 'lib/chunky_png/canvas/stream_exporting.rb', line 25 def to_rgb_stream pixels.pack('NX' * (width * height)) end |
#to_rgba_stream ⇒ String
Creates an RGB-formatted pixelstream with the pixel data from this canvas.
Note that this format is fast but bloated, because no compression is used and the internal representation is left intact. To reconstruct the canvas, the width and height should be known.
14 15 16 |
# File 'lib/chunky_png/canvas/stream_exporting.rb', line 14 def to_rgba_stream pixels.pack('N*') end |