Re: draw on an image
- From: Havoc Pennington <hp redhat com>
- To: Joel Kraehemann <joel2001k yahoo de>
- Cc: gtk-devel-list gnome org
- Subject: Re: draw on an image
- Date: Wed, 21 May 2003 12:33:57 -0400
On Wed, May 21, 2003 at 02:09:56AM +0200, Joel Kraehemann wrote:
> I want to draw directly on an image. I tried something like above but I didn't succeeded.
>
>
> <---->
>
> image = gtk_image_new_from_file ((char *) str);
>
>
> gdk_draw_line (GTK_IMAGE (image)->data.pixmap.pixmap,
> GDK_GC_BACKGROUND,
> 8, 1,
> 8, 3);
>
Drawing on a window or widget should always be done in an expose_event
handler, because the X server discards the window contents anytime the
window is covered up by another window - then sends an expose event
asking them to be redrawn if the window becomes visible again.
You can draw on a pixmap without using expose_event since pixmap
contents are persistent. However, this GtkImage doesn't contain a
pixmap, you loaded it from a file (it thus contains a GdkPixbuf).
Your options are:
- in a GtkImage expose_event handler that runs after the default
handler, draw to GTK_WIDGET (image)->window
- load the pixbuf (gdk_pixbuf_new_from_file()),
draw it to a pixmap (gdk_draw_pixbuf() or
gdk_pixbuf_render_pixmap_and_mask() (?)), set the
pixmap in the GtkImage
- use a drawing area instead of GtkImage
Havoc
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]