gdk_pixbuf2 0.90.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,42 @@
1
+ require 'glib2'
2
+ begin
3
+ begin
4
+ require 'cairo'
5
+ rescue LoadError
6
+ require 'rubygems'
7
+ require 'cairo'
8
+ end
9
+ rescue LoadError
10
+ end
11
+
12
+ base_dir = Pathname.new(__FILE__).dirname.dirname.expand_path
13
+ vendor_dir = base_dir + "vendor" + "local"
14
+ vendor_bin_dir = vendor_dir + "bin"
15
+ GLib.prepend_environment_path(vendor_bin_dir)
16
+ begin
17
+ major, minor, micro, = RUBY_VERSION.split(/\./)
18
+ require "#{major}.#{minor}/gdk_pixbuf2.so"
19
+ rescue LoadError
20
+ require "gdk_pixbuf2.so"
21
+ end
22
+
23
+ module Gdk
24
+ class PixbufLoader
25
+ def self.open(type = nil, mime_type = false)
26
+ loader = Gdk::PixbufLoader.new(type, mime_type)
27
+ if block_given?
28
+ begin
29
+ yield(loader)
30
+ ensure
31
+ loader.close
32
+ end
33
+ end
34
+ loader
35
+ end
36
+ end
37
+ class Pixbuf
38
+ LOG_DOMAIN = "GdkPixbuf"
39
+ end
40
+ end
41
+
42
+ GLib::Log.set_log_domain(Gdk::Pixbuf::LOG_DOMAIN)
data/sample/anim.rb ADDED
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env ruby
2
+ =begin
3
+ anim.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: anim.rb,v 1.5 2006/06/17 14:38:08 mutoh Exp $
9
+ =end
10
+
11
+ require 'gtk2'
12
+
13
+ w = Gtk::Window.new
14
+ w.signal_connect('delete-event') do
15
+ Gtk.main_quit
16
+ end
17
+
18
+ box = Gtk::VBox.new
19
+ src = Gdk::PixbufAnimation.new("floppybuddy.gif")
20
+ box.pack_start(Gtk::Image.new(src))
21
+ p src.width
22
+ p src.height
23
+ p src.static_image?
24
+
25
+ static_image = src.static_image
26
+ box.pack_start(Gtk::Image.new(static_image))
27
+
28
+ iter = src.get_iter
29
+ p iter.advance
30
+ p iter.delay_time
31
+ p iter.on_currently_loading_frame?
32
+
33
+ box.pack_start(Gtk::Image.new(iter.pixbuf))
34
+
35
+ w.add(box)
36
+ w.show_all
37
+
38
+ Gtk.main
@@ -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
data/sample/flip.rb ADDED
@@ -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
data/sample/format.rb ADDED
@@ -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
data/sample/inline.rb ADDED
@@ -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
data/sample/loader.rb ADDED
@@ -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
data/sample/pixdata.rb ADDED
@@ -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
data/sample/rotate.rb ADDED
@@ -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
+
data/sample/save.rb ADDED
@@ -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")
data/sample/scale.rb ADDED
@@ -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