Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 32 lines (24 sloc) 0.786 kb
25bd366 Be helpful: write a descriptive message to stdout when invoked.
rmagick authored
1 #
2 # Demonstrate the export_pixels and import_pixels methods.
3 #
d9b079a Initial revision
tim authored
4
5 require 'RMagick'
6 include Magick
7
25bd366 Be helpful: write a descriptive message to stdout when invoked.
rmagick authored
8 puts <<END_INFO
9
10 This example demonstrates the export_pixels and import_pixels methods
11 by copying an image one row at a time. The result is an copy that
12 is identical to the original.
13
14 END_INFO
15
d9b079a Initial revision
tim authored
16 img = Image.read('../doc/ex/images/Gold_Statue.jpg').first
17 copy = Image.new(img.columns, img.rows);
18
25bd366 Be helpful: write a descriptive message to stdout when invoked.
rmagick authored
19 begin
20 img.rows.times { |r|
21 scanline = img.export_pixels(0, r, img.columns, 1, "RGB");
22 copy.import_pixels(0, r, img.columns, 1, "RGB", scanline);
23 }
24 rescue NotImplementedError
25 $stderr.puts "The export_pixels and import_pixels methods are not supported" +
26 " by this version of ImageMagick/GraphicsMagick"
27 exit
28 end
d9b079a Initial revision
tim authored
29
bb192ae Fix example so it will work "out of the box" on Windows
rmagick authored
30 copy.write("copy.gif")
d9b079a Initial revision
tim authored
31 exit
Something went wrong with that request. Please try again.