Sha256: 57a5fac909a5867a5f21c73232212f4d2724c5dae12a03f4bf1eba6b413f9761
Contents?: true
Size: 1.45 KB
Versions: 30
Compression:
Stored size: 1.45 KB
Contents
module ChunkyPNG class Canvas # Methods to save load a canvas from to stream, encoded in RGB, RGBA, BGR or ABGR format. module StreamExporting # 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. def to_rgba_stream pixels.pack('N*') 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. def to_rgb_stream pixels.pack('NX' * (width * height)) end # 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. def to_abgr_stream pixels.pack('V*') end end end end
Version data entries
30 entries across 30 versions & 1 rubygems