cgtk

display a image from the internet in gtk


I wanna display a image from the internet how can I put it?


Solution

  • 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.