lib/chunky_png/canvas/stream_importing.rb
# Creates a canvas by reading pixels from an BGR formatted stream with a
# provided with and height.
#
# Every pixel should be represented by 3 bytes in the stream, in the correct
# BGR order. This format closely resembles the internal representation of a
# canvas object, so this kind of stream can be read extremely quickly.
#
# @param [Integer] width The width of the new canvas.
# @param [Integer] height The height of the new canvas.
# @param [#read, String] stream The stream to read the pixel data from.
# @return [ChunkyPNG::Canvas] The newly constructed canvas instance.
Creates a canvas by reading pixels from an BGR formatted stream with a
provided with and height.

Every pixel should be represented by 3 bytes in the stream, in the correct
BGR order. This format closely resembles the internal representation of a
canvas object, so this kind of stream can be read extremely quickly.
Creates a canvas by reading pixels from an BGR formatted stream with a provided with and height . Every pixel should be represented by 3 bytes in the stream in the correct BGR order . This format closely resembles the internal representation of a canvas object so this kind of stream can be read extremely quickly .
def from_bgr_stream(width, height, stream)
        string = ChunkyPNG::EXTRA_BYTE.dup 
        string << (stream.respond_to?(:read) ? stream.read(3 * width * height) : stream.to_s[0, 3 * width * height])
        pixels = string.unpack("@1#{"XV" * (width * height)}").map { |color| color | 0x000000ff }
        new(width, height, pixels)
      end
def from_bgr_stream ( width , height , stream ) string = ChunkyPNG :: EXTRA_BYTE . dup string << ( stream . respond_to? ( :read ) ? stream . read ( 3 * width * height ) : stream . to_s [ 0 , 3 * width * height ] ) pixels = string . unpack ( "@1#{"XV" * (width * height)}" ) . map { | color | color | 0x000000ff } new ( width , height , pixels ) end
Creates a canvas by reading pixels from an BGR formatted stream with a
provided with and height.
Creates a canvas by reading pixels from an BGR formatted stream with a provided with and height .
# Add a first byte to the first BGR triple.
The newly constructed canvas instance.
The newly constructed canvas instance .
ChunkyPNG::Canvas
width
<not_specific>
height
<not_specific>
stream
<not_specific>
<not_specific>
stream The stream to read the pixel data from.
stream The stream to read the pixel data from .