Gdk::Pixbuf from an URL

Hi,

I wanna display a image from the internet in a Gdk::Pixbuf. Pixbuf.new
only accepts files on the harddisc. So my idea was to use
Pixbuf#from_image. But therefore I have to load the image in a Gdk::Image.
I've found out, that I can download an image with net/http. I can read the
file, but how can I put it in a Gdk::Image? Any ideas?

Greetings

Michael

Hi,

···

On Sat, 12 Feb 2005 00:10:01 +0900 Michael Gebhart <mail@miketech.net> wrote:

Hi,

I wanna display a image from the internet in a Gdk::Pixbuf. Pixbuf.new
only accepts files on the harddisc. So my idea was to use
Pixbuf#from_image. But therefore I have to load the image in a Gdk::Image.
I've found out, that I can download an image with net/http. I can read the
file, but how can I put it in a Gdk::Image? Any ideas?

Interesting Quiz ;).

My answer is:

-------------------
require 'open-uri'
require 'gtk2'

Gtk.init
loader = Gdk::PixbufLoader.new
open("http://www.ruby-lang.org/image/title.gif") { |f|
  loader.last_write(f.read)
}
pixbuf = loader.pixbuf

Gtk::Window.new.add(Gtk::Image.new(pixbuf)).show_all
Gtk.main
-------------------

#This example for Ruby-1.8.x or later.

--
.:% Masao Mutoh<mutoh@highway.ne.jp>

Great.. really great!

Thanks a lot

Michael