gdk_draw_pixbuf()



<Warning>I have no prior experience programming with gtk, other than a few of the tutorials on gtk.org</Warning>

I am having some trouble with this code. From what I can tell from the docs this should work, and it should draw the linux.png image on the window. It compiles ok, and when runs the window is shown, but does not appear to be drawing the image.

A few notes about what I have tried:
1. I tested pixbuf after the call to gdk_pixbuf_new_from_file() to see if it was NULL and it was _not_. 2. I am passing NULL to the second parameter gdk_pixbuf_new_from_file() because I can't figure out how to use the GError object. 3. After reading through the docs I thought that the Colormap might have something to do with it, so i tried creating one (the commented code). I was going to apply it to the window and then pass it to the call to gdk_draw_pixbuf(), but could not successfully create one using gdk_colormap_get_system().

Any assistance would be greatly appreciated.

Thanks,

Nick

--code--

#include <gtk/gtk.h>

void close_application( GtkWidget *widget, GdkEvent
*event, gpointer data ) {
        gtk_main_quit();
}

int main (int argc, char *argv[])
{
        GtkWidget *window;
        GdkPixbuf *pixbuf;
        //GdkColormap *colormap;

        gtk_init (&argc, &argv);

        //colormap = gdk_colormap_get_system();
        window = gtk_window_new( GTK_WINDOW_TOPLEVEL);
        //gdk_drawable_set_colormap(window->window, colormap);

        gtk_signal_connect (GTK_OBJECT (window), "delete_event",
                        GTK_SIGNAL_FUNC (close_application), NULL);
        gtk_widget_show (window);

        pixbuf = gdk_pixbuf_new_from_file((gchar *) "linux.png", NULL);

gdk_draw_pixbuf(window->window, NULL, GDK_PIXBUF (pixbuf),0,0,0,0,-1,-1,GDK_RGB_DITHER_NONE,0,0);
        gtk_main ();

    return 0;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]