开发者

display a image from the internet in gtk

开发者 https://www.devze.com 2022-12-11 11:35 出处:网络
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.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消