lib/vips/image.rb
# Convert to an Array. This will be slow for large images. 
#
# @return [Array] array of Fixnum
Convert to an Array. This will be slow for large images.
Convert to an Array . This will be slow for large images .
def to_a
            memory = write_to_memory
            template = {
                :char => 'c',
                :uchar => 'C',
                :short => 's_',
                :ushort => 'S_',
                :int => 'i_',
                :uint => 'I_',
                :float => 'f',
                :double => 'd',
                :complex => 'f',
                :dpcomplex => 'd'
            }[format] + '*'
            array = memory.unpack(template)
            pixel_array = array.each_slice(bands).to_a
            row_array = pixel_array.each_slice(width).to_a
            return row_array
        end
def to_a memory = write_to_memory template = { :char => 'c' , :uchar => 'C' , :short => 's_' , :ushort => 'S_' , :int => 'i_' , :uint => 'I_' , :float => 'f' , :double => 'd' , :complex => 'f' , :dpcomplex => 'd' } [ format ] + '*' array = memory . unpack ( template ) pixel_array = array . each_slice ( bands ) . to_a row_array = pixel_array . each_slice ( width ) . to_a return row_array end
Convert to an Array.
Convert to an Array .
# we render the image to a big string, then unpack  # as a Ruby array of the correct type # make the template for unpack # and unpack into something like [1, 2, 3, 4 ..] # gather band elements together # build rows 
array of Fixnum
array of Fixnum
Array