Re: drawing an RGB bitmap or pixbuf



Matt Hull schrieb:
I am new to gtk and trying to draw a bitmap to the screen.  the bitmap is
about 200 by 300 pixels with 8 bit rgb, total is 24 bits.  alpha is
optional at the moment.

But important is only that it should be in a file format supported
by GTK (png, xpm, etc.)

for now it is 0xff.  i have tried many different
examples from the internet but none seem to work.  can anyone give me an
example ?  maybe just draw it once to get me started or put it in a timer
loop to be called when idle ?

Not, it's not needed, it redraw itself.

Please have a look at the docs!

Cheers,

Andy


Here a short example without error checking (!).

#include <gtk/gtk.h>

int main(int argc, char *argv[]) {
    GtkWidget *w, *p;
    gtk_init(&argc, &argv);

    w = gtk_window_new(GTK_WINDOW_TOPLEVEL);
    g_signal_connect(G_OBJECT(w), "destroy",
                     G_CALLBACK(gtk_main_quit), NULL);

    p = gtk_image_new_from_file("test.png");
    gtk_widget_show(GTK_WIDGET(p)); /* dont forget show() */
    gtk_container_add(GTK_CONTAINER(w), GTK_WIDGET(p));

    gtk_widget_show(GTK_WIDGET(w)); /* dont forget show() */

    gtk_main();
    return 0;
}



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