display a image from the internet in gtk
I wanna display a image from the internet how can I put it开发者_运维技巧?
GTK+ doesn't read files from the Internet, you're going to have to do that part yourself.
Once you have the pixel data in memory in a known format (such as JPEG or PNG), call gdk_pixbuf_new_from_stream()
(after setting up an in-memory stream) to load it.
Then hand that pixbuf to gtk_image_new_from_pixbuf()
, add your GtkImage to a GtkWindow, call gtk_widget_show_all()
on the window, and you should be done.
I know it's an old post but I'll elaborate for anyone who stumbles upon this thread.
You'll want to use libsoup for this, it ties into the GLib main loop and can therefore work asynchronously.
https://libsoup.org/libsoup-2.4/libsoup-client-howto.html
精彩评论