Sha256: 1289c611e9a09266ffc28e6e1bf9358a9de09d99b808b588fdd7308cfd0e9299

Contents?: true

Size: 1.01 KB

Versions: 39

Compression:

Stored size: 1.01 KB

Contents

#! /usr/local/bin/ruby -w
require 'RMagick'

f = Magick::Image.read("images/Flower_Hat.jpg").first

pixels = f.dispatch(0,0,f.columns,f.rows,"RGB")

# Write the pixels to a file, to be loaded in the Zconstitute.rb
# example.  Ruby 1.6.8 # loads the Pixels array much faster if we break
# the array into many small pieces and concatenate them together, so this
# program generates such a sequence.

first = true
total = pixels.length

File.open('pixels-array', 'w') { |txt|
    txt.puts("Width = #{f.columns}")
    txt.puts("Height = #{f.rows}")
    txt.puts('Pixels = [')
    x = 0
    pixels.each do |p|
        txt.printf("%3d,", p)
        x = x.succ
        txt.printf("\n") if x % 25 == 0
        if x % 1000 == 0
            if first
                txt.puts(']')
                first = false
            else
                txt.puts('])')
            end
            txt.print('Pixels.concat([')
        end
    end

    if first
        txt.puts(']')
        first = false
    else
        txt.puts('])')
    end
}
exit

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
rmagick-1.10.1 doc/ex/Adispatch.rb
rmagick-1.10.0 doc/ex/Adispatch.rb
rmagick-1.13.0 doc/ex/Adispatch.rb
rmagick-1.12.0 doc/ex/Adispatch.rb
rmagick-1.11.1 doc/ex/Adispatch.rb
rmagick-1.11.0 doc/ex/Adispatch.rb
rmagick-1.15.10 doc/ex/Adispatch.rb
rmagick-1.14.0 doc/ex/Adispatch.rb
rmagick-1.14.1 doc/ex/Adispatch.rb
rmagick-1.15.0 doc/ex/Adispatch.rb
rmagick-1.15.1 doc/ex/Adispatch.rb
rmagick-1.15.11 doc/ex/Adispatch.rb
rmagick-1.15.13 doc/ex/Adispatch.rb
rmagick-1.15.15 doc/ex/Adispatch.rb
rmagick-1.15.14 doc/ex/Adispatch.rb
rmagick-1.15.12 doc/ex/Adispatch.rb
rmagick-1.15.2 doc/ex/Adispatch.rb
rmagick-1.15.4 doc/ex/Adispatch.rb
rmagick-1.15.16 doc/ex/Adispatch.rb
rmagick-1.15.17 doc/ex/Adispatch.rb