gdkpixbuf 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ composite.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: composite.rb,v 1.6 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ filename = ARGV[0]
14
+ unless filename
15
+ puts "ruby #{$0} filename"
16
+ exit(1)
17
+ end
18
+
19
+ src = Gdk::Pixbuf.new(filename)
20
+
21
+ vbox = Gtk::VBox.new
22
+
23
+ dst = src.composite(100, 100, Gdk::Pixbuf::INTERP_HYPER,
24
+ 200, 32, 0xFF0000, 0x00FF00)
25
+ vbox.pack_start(Gtk::Image.new(dst))
26
+
27
+ dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200)
28
+ dst.composite!(src, 0, 0, 200, 200, 0, 0, 1.8, 1.8,
29
+ Gdk::Pixbuf::INTERP_HYPER, 200)
30
+ vbox.pack_start(Gtk::Image.new(dst))
31
+
32
+ dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200)
33
+ dst.composite!(src, 10, 10, 180, 180, 15, 15, 3, 2,
34
+ Gdk::Pixbuf::INTERP_BILINEAR, 200, 100, 100, 16,
35
+ 0x999999, 0xdddddd)
36
+ vbox.pack_start(Gtk::Image.new(dst))
37
+
38
+ window = Gtk::Window.new.add(vbox)
39
+ window.signal_connect('delete-event') do
40
+ Gtk.main_quit
41
+ end
42
+
43
+ window.show_all
44
+
45
+ Gtk.main
@@ -0,0 +1,47 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ flip.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2005,2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: flip.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+
14
+ filename = ARGV[0]
15
+ unless filename
16
+ puts "ruby #{$0} filename"
17
+ exit(1)
18
+ end
19
+
20
+ if str = Gtk.check_version(2, 6, 0)
21
+ puts "This sample requires GTK+ 2.6.0 or later"
22
+ puts str
23
+ exit
24
+ end
25
+
26
+ vbox = Gtk::VBox.new
27
+
28
+ src = Gdk::Pixbuf.new(filename)
29
+ vbox.add(Gtk::Image.new(src))
30
+
31
+ # Horizontal
32
+ dst = src.flip(true)
33
+ vbox.add(Gtk::Image.new(dst))
34
+
35
+ # Vertical
36
+ dst2 = src.flip(false)
37
+ vbox.add(Gtk::Image.new(dst2))
38
+
39
+ window = Gtk::Window.new
40
+ window.signal_connect('delete-event') do
41
+ Gtk.main_quit
42
+ end
43
+
44
+ window.add(vbox).show_all
45
+
46
+ Gtk.main
47
+
Binary file
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ format.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2004-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: format.rb,v 1.4 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ if str = Gtk.check_version(2, 2, 0)
14
+ puts "This sample requires GTK+ 2.2.0 or later"
15
+ puts str
16
+ exit
17
+ end
18
+
19
+ filename = ARGV[0]
20
+ unless filename
21
+ puts "ruby #{$0} filename"
22
+ exit(1)
23
+ end
24
+
25
+ puts fileinfo = Gdk::Pixbuf.get_file_info(filename)[0]
26
+ puts "name = #{fileinfo.name}"
27
+ puts "description = #{fileinfo.description}"
28
+ puts "mime_types = #{fileinfo.mime_types.inspect}"
29
+ puts "extensions = #{fileinfo.extensions.inspect}"
30
+ puts "writable = #{fileinfo.writable?}"
31
+ puts "domain = #{fileinfo.domain}"
32
+ puts "signature = #{fileinfo.signature.inspect}"
33
+
34
+ if Gtk.check_version?(2, 6, 0)
35
+ puts "Since 2.6 --- "
36
+ puts "scalable = #{fileinfo.scalable?}"
37
+ puts "disabled = #{fileinfo.disabled?}"
38
+ puts "license = #{fileinfo.license.inspect}"
39
+ end
Binary file
@@ -0,0 +1,37 @@
1
+ =begin
2
+ inline.rb - Ruby/GdkPixbuf sample script.
3
+
4
+ Copyright (c) 2004-2006 Ruby-GNOME2 Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME2.
6
+
7
+ $Id: inline.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $
8
+ =end
9
+
10
+ require 'gtk2'
11
+
12
+ pixbuf = Gdk::Pixbuf.new("gnome-foot.png")
13
+
14
+ #pixbuf = Gdk::Pixbuf.new(ARGV[0])
15
+
16
+ # Create Gdk::Pixbuf from pixels(String).
17
+ pixbuf2 = Gdk::Pixbuf.new(pixbuf.pixels, Gdk::Pixbuf::COLORSPACE_RGB,
18
+ true, pixbuf.bits_per_sample,
19
+ pixbuf.width, pixbuf.height,
20
+ pixbuf.rowstride)
21
+
22
+ # Create Gdk::Pixbuf from an array of numbers
23
+ # which created by Gdk::Pixdata#serialize.
24
+ pixdata = Gdk::Pixdata.from_pixbuf(pixbuf, false)
25
+ data = pixdata.serialize
26
+ pixbuf3 = Gdk::Pixbuf.new(data, false)
27
+
28
+ # Create Gdk::Pixbuf from Gdk::Pixbuf.
29
+ pixbuf4 = Gdk::Pixbuf.new(pixbuf, 10, 10, 20, 20)
30
+
31
+ vbox = Gtk::VBox.new
32
+ vbox.add(Gtk::Image.new(pixbuf))
33
+ vbox.add(Gtk::Image.new(pixbuf2))
34
+ vbox.add(Gtk::Image.new(pixbuf3))
35
+ vbox.add(Gtk::Image.new(pixbuf4))
36
+ Gtk::Window.new.add(vbox).show_all
37
+ Gtk.main
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ loader.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2003,2006: Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: loader.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+ require 'gtk2'
11
+
12
+ loader = Gdk::PixbufLoader.new
13
+ File.open("gnome-foot.png","rb") { |f|
14
+ loader.last_write(f.read)
15
+ }
16
+ pixbuf = loader.pixbuf
17
+
18
+ Gtk::Window.new.add(Gtk::Image.new(pixbuf)).show_all
19
+
20
+ Gtk.main
@@ -0,0 +1,39 @@
1
+ =begin
2
+ pixdata.rb - Ruby/GdkPixbuf sample script.
3
+
4
+ Copyright (c) 2004-2006 Ruby-GNOME2 Project Team
5
+ This program is licenced under the same licence as Ruby-GNOME2.
6
+
7
+ $Id: pixdata.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $
8
+ =end
9
+ require 'gtk2'
10
+
11
+ r_xpm = [
12
+ "10 10 3 1",
13
+ " c None",
14
+ ". c #FE0B0B",
15
+ "+ c #FFFFFF",
16
+ "+.......++",
17
+ "+.. ..+",
18
+ "+.. ..+",
19
+ "+.. ...+",
20
+ "+.......++",
21
+ "+.....++++",
22
+ "+..++..+++",
23
+ "+..++...++",
24
+ "+..+++...+",
25
+ "+..++++..+"]
26
+
27
+ pixbuf = Gdk::Pixbuf.new(r_xpm)
28
+ pixdata = Gdk::Pixdata.from_pixbuf(pixbuf, false)
29
+
30
+ #Serialize data
31
+ p data = pixdata.serialize
32
+
33
+ #Deserialize data
34
+ pixdata = Gdk::Pixdata.deserialize(data)
35
+ pixbuf2 = pixdata.to_pixbuf(false)
36
+
37
+ dst = pixbuf2.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER)
38
+ Gtk::Window.new.add(Gtk::Image.new(dst)).show_all
39
+ Gtk.main
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ rotate.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2005,2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: rotate.rb,v 1.3 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+
14
+ filename = ARGV[0]
15
+ unless filename
16
+ puts "ruby #{$0} filename"
17
+ exit(1)
18
+ end
19
+
20
+ if str = Gtk.check_version(2, 6, 0)
21
+ puts "This sample requires GTK+ 2.6.0 or later"
22
+ puts str
23
+ exit
24
+ end
25
+
26
+ vbox = Gtk::VBox.new
27
+
28
+ src = Gdk::Pixbuf.new(filename)
29
+ vbox.add(Gtk::Image.new(src))
30
+
31
+ dst = src.rotate(Gdk::Pixbuf::ROTATE_COUNTERCLOCKWISE)
32
+ vbox.add(Gtk::Image.new(dst))
33
+
34
+ dst2 = src.rotate(Gdk::Pixbuf::ROTATE_UPSIDEDOWN)
35
+ vbox.add(Gtk::Image.new(dst2))
36
+
37
+ window = Gtk::Window.new
38
+ window.signal_connect('delete-event') do
39
+ Gtk.main_quit
40
+ end
41
+
42
+ window.add(vbox).show_all
43
+
44
+ Gtk.main
45
+
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ save.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: save.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gdk_pixbuf2'
12
+
13
+ from = ARGV[0]
14
+ to = ARGV[1]
15
+ if ! from or ! to
16
+ puts "ruby #{$0} from_file to_file"
17
+ exit(1)
18
+ end
19
+
20
+ src = Gdk::Pixbuf.new(from)
21
+
22
+ dst = src.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER)
23
+ # This doesn't work ....
24
+ #dst.save(to, "jpeg", {:quality => 100})
25
+ dst.save(to, "png")
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ scale.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: scale.rb,v 1.10 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ filename = ARGV[0]
14
+ unless filename
15
+ puts "ruby #{$0} filename"
16
+ exit(1)
17
+ end
18
+
19
+ vbox = Gtk::VBox.new
20
+
21
+ src = Gdk::Pixbuf.new(filename)
22
+ vbox.add(Gtk::Image.new(src))
23
+
24
+ dst = src.scale(200, 200, Gdk::Pixbuf::INTERP_NEAREST)
25
+ dst.scale!(src, 60, 60, 90, 90, -50, 50, 6, 3)
26
+ vbox.add(Gtk::Image.new(dst))
27
+
28
+ dst2 = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200)
29
+ dst2.scale!(src, 0, 0, 100, 100, 0, 0, 1.5, 1.5)
30
+
31
+ vbox.add(Gtk::Image.new(dst2))
32
+
33
+ dst3 = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8, 200, 200)
34
+ dst3.scale!(src, 0, 0, 200, 200, 0, 0, 5, 3, Gdk::Pixbuf::INTERP_HYPER)
35
+ vbox.add(Gtk::Image.new(dst3))
36
+
37
+ window = Gtk::Window.new
38
+ window.signal_connect('delete-event') do
39
+ Gtk.main_quit
40
+ end
41
+
42
+ window.add(vbox).show_all
43
+
44
+ Gtk.main
45
+
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ simpleanim.rb - Ruby/GdkPixbuf sample script for Gdk::PixbufSimpleAnim.
4
+
5
+ Inspired by http://mail.gnome.org/archives/gtk-perl-list/2005-September/msg00110.html
6
+
7
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
8
+ This program is licenced under the same licence as Ruby-GNOME2.
9
+
10
+ $Id: simpleanim.rb,v 1.2 2006/06/17 14:38:08 mutoh Exp $
11
+ =end
12
+
13
+ require 'gtk2'
14
+
15
+ $stdout.sync = true
16
+
17
+ simple_anim = Gdk::PixbufSimpleAnim.new(64, 64, 24)
18
+ store_pixels = []
19
+
20
+ print 'generating frames'
21
+ for red in 0 .. 126
22
+ store_pixels << pixels = ([ 4*(63-red).abs, 0, 0 ] * (64*64)).pack('C*')
23
+ pixbuf = Gdk::Pixbuf.new(pixels, Gdk::Pixbuf::COLORSPACE_RGB, false, 8, 64, 64, 64*3)
24
+ simple_anim.add_frame(pixbuf)
25
+ print '.'
26
+ end
27
+ puts 'done'
28
+
29
+ window = Gtk::Window.new
30
+ image = Gtk::Image.new(simple_anim)
31
+ window.add(image)
32
+ window.show_all
33
+ window.signal_connect('destroy') { Gtk.main_quit }
34
+ Gtk.main
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ utils.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: utils.rb,v 1.4 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ filename = ARGV[0]
14
+ unless filename
15
+ puts "ruby #{$0} filename"
16
+ exit(1)
17
+ end
18
+
19
+ src = Gdk::Pixbuf.new(filename)
20
+
21
+ vbox = Gtk::VBox.new
22
+
23
+ dst = src.add_alpha(true, 0, 0, 0)
24
+ vbox.pack_start(Gtk::Image.new(dst))
25
+
26
+ dst = Gdk::Pixbuf.new(Gdk::Pixbuf::COLORSPACE_RGB, true, 8,
27
+ src.width + 20, src.height + 30)
28
+ src.copy_area(0, 0, src.width / 2, src.height / 2, dst, 10, 20)
29
+ vbox.pack_start(Gtk::Image.new(dst))
30
+
31
+ dst = src.saturate_and_pixelate(0.3, true)
32
+ vbox.pack_start(Gtk::Image.new(dst))
33
+
34
+ dst = src.fill!(0xff000099) #RGBA
35
+ vbox.pack_start(Gtk::Image.new(dst))
36
+
37
+ w = Gtk::Window.new.add(vbox)
38
+ w.signal_connect('delete-event') do
39
+ Gtk.main_quit
40
+ end
41
+
42
+ w.show_all
43
+
44
+ Gtk.main
@@ -0,0 +1,40 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ xpm.rb - Ruby/GdkPixbuf sample script.
4
+
5
+ Copyright (c) 2002-2006 Ruby-GNOME2 Project Team
6
+ This program is licenced under the same licence as Ruby-GNOME2.
7
+
8
+ $Id: xpm.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ r_xpm = [
14
+ "10 10 3 1",
15
+ " c None",
16
+ ". c #FE0B0B",
17
+ "+ c #FFFFFF",
18
+ "+.......++",
19
+ "+.. ..+",
20
+ "+.. ..+",
21
+ "+.. ...+",
22
+ "+.......++",
23
+ "+.....++++",
24
+ "+..++..+++",
25
+ "+..++...++",
26
+ "+..+++...+",
27
+ "+..++++..+"]
28
+
29
+ w = Gtk::Window.new
30
+ w.signal_connect('delete-event') do
31
+ Gtk.main_quit
32
+ end
33
+
34
+ src = Gdk::Pixbuf.new(r_xpm)
35
+ dst = src.scale(300, 300, Gdk::Pixbuf::INTERP_HYPER)
36
+
37
+ w.add(Gtk::Image.new(dst))
38
+ w.show_all
39
+
40
+ Gtk.main