Module ChunkyPNG::Canvas::StreamExporting
In: lib/chunky_png/canvas/stream_exporting.rb

Methods to save load a canvas from to stream, encoded in RGB, RGBA, BGR or ABGR format.

Methods

Public Instance methods

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.

@return [String] The RGBA-formatted pixel data.

[Source]

    # File lib/chunky_png/canvas/stream_exporting.rb, line 53
53:       def to_abgr_stream
54:         pixels.pack('V*')
55:       end

Creates a stream of the alpha channel of this canvas.

@return [String] The 0-255 alpha values of all pixels packed as string

[Source]

    # File lib/chunky_png/canvas/stream_exporting.rb, line 32
32:       def to_alpha_channel_stream
33:         pixels.pack('C*')
34:       end

Creates a grayscale stream of this canvas.

This method assume sthat this image is fully grayscale, i.e. R = G = B for every pixel. The alpha channel will not be included in the stream.

@return [String] The 0-255 grayscale values of all pixels packed as string.

[Source]

    # File lib/chunky_png/canvas/stream_exporting.rb, line 42
42:       def to_grayscale_stream
43:         pixels.pack('nX' * pixels.length)
44:       end

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.

@return [String] The RGB-formatted pixel data.

[Source]

    # File lib/chunky_png/canvas/stream_exporting.rb, line 25
25:       def to_rgb_stream
26:         pixels.pack('NX' * pixels.length)
27:       end

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.

@return [String] The RGBA-formatted pixel data.

[Source]

    # File lib/chunky_png/canvas/stream_exporting.rb, line 14
14:       def to_rgba_stream
15:         pixels.pack('N*')
16:       end

[Validate]