Image Download, C and GTK

I keep getting a broken image (red “X” in the document, it doesn’t even load the one I want, I don’t know if this is clear enough) and don’t know why, here it is what I tried:

image = gtk_image_new_from_file("abc.png");
gtk_container_add (GTK_CONTAINER (window), image);
gtk_widget_show (image);
gtk_widget_show (window);`

I am new to GUI programming, so please be beautiful! Ha

I forgot to say it's under the windows

UPDATE: noticed that the error is in "gdk_pixbuf_new_from_file", it returns me the error value, cannot solve the problem yet

If I run the debugger, it says: "Error loading file: # 4 Could not open file" abc.jpeg ": there is no such file or directory," should it be in the folder where the executable file is located? anyway, if I put the full path, he will not find it either

+3
source share
3 answers

( ), Windows GTK+. GTK +, gdk-pixbuf, , () , . glib API . Gdk-pixbuf , . Windows glib , . GTK + , , , . , , " " , , " ". , , ?

, ( PCManFM) , gdk_pixbuf_loader_new_with_mime_type(). , .

+2

, GdkPixbuf. lib/gtk-2.0/2.10.0/loaders/. libpixbufloader-bmp.dll, .

, :

GError *error = NULL;
GdkPixbuf *pix = gdk_pixbuf_new_from_file ("abc.png", &error);
if (pix == NULL) {
    g_printerr ("Error loading file: #%d %s\n", error->code, error->message);
    g_error_free (error);
    exit (1);
}
GtkWidget *widget = gtk_image_new_from_pixbuf (pix);

.

0

Glib/Gtk stdout/stderr, ? "strace -eopen", , ? , ?

0

Source: https://habr.com/ru/post/1727372/


All Articles