Re: gdk_draw_image() not working?
- From: jcupitt gmail com
- To: Tomasz Sterna <tomek xiaoka com>
- Cc: gtk-app-devel-list gnome org
- Subject: Re: gdk_draw_image() not working?
- Date: Wed, 9 Jun 2010 12:35:37 +0100
On 8 June 2010 23:22, Tomasz Sterna <tomek xiaoka com> 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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]