Re: Draw in a GdkPixbuf



Thanks for your advice.

Unfortunately, this doesn't help here, since all the examples you cite use GTK, so they don't have the same problem, as they draw on existing drawables. What I want is drawing on an image that will not be rendered on screen. So I have no graphical context, just a GdkPixbuf as an input, and I want to modify that image to save it in a file. There's no problem for me if I don't work directly on the GdkPixbuf: something that will convert the GdkPixbuf into somethins else that I can draw on is an acceptable solution.

Cheers,

Luis

James Scott Jr a écrit :
Take a look at the executable 'gtk-demo'.  It should have been installed
with gtk's development tools; i.e. already loaded on you machine.  Hint:
double click the sample for a live preview, then look at the source
code.

Additionally, here is a link to glinegraph, a simple line graph widget
written twice, once in gdk and again in cairo.

http://sourceforge.net/project/showfiles.php?group_id=157888&package_id=191712

James,




On Thu, 2008-05-29 at 03:18 +0200, Luis Menina wrote:
Hi list!

I'm trying to find a way to draw in a GdkPixbuf (for example draw a rectangle on the pixbuf) and save the result to a file afterwards.

I found in devhelp the gdk_draw_* functions, but to use them I need a GdkPixmap. gdk_pixmap_new requires a GdkDrawable. The problem is that I'm developping a command line application, so I don't use GTK, only glib, gdk, and gdk-pixbuf. Even creating the GdkPixmap with a NULL GdkDrawable, I can't workaround the problem, because the documentation of gdk_draw_pixbuf tells me that "All windows have a colormap, however, pixmaps only have colormap by default if they were created with a non-NULL window argument. Otherwise a colormap must be set on them with gdk_drawable_set_colormap()". Trying to get a colormap requires other stuff, which requires other stuff, and so on...

As this seems to be quite old-fashioned way of doing things, I tried to see if cairo could do the trick. But it seems there's no way to draw to a GdkPixbuf with cairo (I'm unfamiliar with cairo).

So, does anyone have an hint on how to draw and save an image from a GdkPixbuf, with gdk or cairo ?

Thanks for you help,

Luis
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





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