On 8 June 2010 23:22, Tomasz Sterna <[email protected]> wrote:
> I am using the following code (stripped):
>
> ---- 8< ----
> drawing = gtk_drawing_area_new ();
> gc = gdk_gc_new (drawing->window);
> image = gdk_image_new (GDK_IMAGE_FASTEST,
> gdk_visual_get_system(), w, h );
> paint_image (image->mem); // custom painting function
> gdk_draw_image (drawing->window, gc,
> image, 0, 0, 0, 0, -1, -1 );
> ---- 8< ----
>
> and I don't see my image on screen :-(
You need to call gdk_draw_image() in your expose handler. Something like:
drawing = gtk_drawing_area_new ();
g_signal_connect (drawing, "expose", my_expose, my_state);
static gint
my_expose (GtkWidget *widget, GdkEventExpose *event, my_state)
{
GdkRectangle *rect;
int i, n;
gc = ...
gdk_region_get_rectangles( event->region, &rect, &n );
for( i = 0; i < n; i++ ) {
image = ... build the area at: rect[i].x, rect[i].y,
rect[i].width, rect[i].height
gdk_draw_rgb_image (widget, gc, ... );
}
g_free( rect );
return( FALSE );
}
Though that's a bit old-fashioned now, I think all the cool kids use Cairo.
John
_______________________________________________
gtk-app-devel-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list