Sha256: 36f99fdc3864d08de59a2275f77c12d49dbfdc3a2df7eb273e55c621a8b242ce

Contents?: true

Size: 756 Bytes

Versions: 6

Compression:

Stored size: 756 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
  warn '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

6 entries across 6 versions & 1 rubygems

Version Path
rmagick-4.1.0.rc2 examples/import_export.rb
rmagick-4.1.0.rc1 examples/import_export.rb
rmagick-4.0.0 examples/import_export.rb
rmagick-3.2.0 examples/import_export.rb
rmagick-3.1.0 examples/import_export.rb
rmagick-3.0.0 examples/import_export.rb