I have not used GDK so far but the errors are quite clear.
Both are sourced by your
image
being
NULL
. You have to create a new empty
GtkImage
widget first:
image = gtk_image_new();
Note also that you should check if loading from the files was successful:
buf = gdk_pixbuf_new_from_file("1.jpg", &err);
if (NULL == buf)
{
fprintf(stderr, "Loading image 1 failed with error %s\n", err->message);
return 1;
}
buf2 = gdk_pixbuf_new_from_file("2.jpg", &err);
if (NULL == buf2)
{
fprintf(stderr, "Loading image 2 failed with error %s\n", err->message);
return 1;
}
You have not specified a full path to the image files. Then the current working directory is used. If that does not contain the image files, loading will fail.