module ChunkyPNG::Canvas::StreamImporting
def from_rgba_stream(width, height, stream)
-
(ChunkyPNG::Canvas)
- The newly constructed canvas instance.
Parameters:
-
stream
(#read, String
) -- The stream to read the pixel data from. -
height
(Integer
) -- The height of the new canvas. -
width
(Integer
) -- The width of the new canvas.
def from_rgba_stream(width, height, stream) string = stream.respond_to?(:read) ? stream.read(4 * width * height) : stream.to_s[0, 4 * width * height] new(width, height, string.unpack("N*")) end