Sha256: 524d3fd6d80baa81c8ad34707c2e0bd3406f27173140f599301c83bf90c28096

Contents?: true

Size: 764 Bytes

Versions: 13

Compression:

Stored size: 764 Bytes

Contents

#
# Demonstrate the export_pixels and import_pixels methods.
#

require 'rmagick'
include Magick

puts <<END_INFO

This example demonstrates the export_pixels and import_pixels methods
by copying an image one row at a time. The result is an copy that
is identical to the original.

END_INFO

img = Image.read('../doc/ex/images/Gold_Statue.jpg').first
copy = Image.new(img.columns, img.rows)

begin
  img.rows.times do |r|
    scanline = img.export_pixels(0, r, img.columns, 1, 'RGB')
    copy.import_pixels(0, r, img.columns, 1, 'RGB', scanline)
  end
rescue NotImplementedError
  $stderr.puts 'The export_pixels and import_pixels methods are not supported' \
               ' by this version of ImageMagick/GraphicsMagick'
  exit
end

copy.write('copy.gif')
exit

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
rmagick-windows-2.16.5 examples/import_export.rb
rmagick-windows-2.16.4 examples/import_export.rb
rmagick-windows-2.16.3 examples/import_export.rb
rmagick-windows-2.16.2 examples/import_export.rb
rmagick-windows-2.16.1 examples/import_export.rb
mdg-1.0.1 vendor/bundle/ruby/2.3.0/gems/rmagick-2.16.0/examples/import_export.rb
rmagick-2.16.0 examples/import_export.rb
rmagick-2.15.4 examples/import_export.rb
rmagick-2.15.3 examples/import_export.rb
rmagick-2.15.2 examples/import_export.rb
rmagick-2.15.1 examples/import_export.rb
rmagick-2.15.0 examples/import_export.rb
rmagick-2.14.0 examples/import_export.rb