Luis Gonzalez wrote:
> Hi to all ,
>
> I have a gtk.Image load from file.
>
> I want to write text inside this Image and then write to a file (jpg or png).
>
> I try to do use gtk.gdk.Pixbuf but to write text , draw lines , draw 
> rectangle I need a drawable object like gtk.gdk.Pixmap.
>
> How can i do this?
>   
If you want to read an image from a file draw on it and write it back 
you don't need to use a gtk.Image - that's only used for displaying an 
image. In fact you don't need PyGTK you can use cairo or PIL to do the 
job. If however you are using PyGTK anyway or are also going to use the 
image within PyGTK, the basic procedure is:

- load a pixbuf with the image from a file using 
gtk.gdk.pixbuf_new_from_file()
- create a pixmap of the same size using gtk.gdk.Pixmap() or 
gtk.gdk.Pixbuf.render_pixmap_and_mask()
- draw the pixbuf image on the pixmap using 
gtk.gdk.Drawable.draw_pixbuf() (not needed if render_pixmap_and_mask was 
used)
- draw your text, lines, etc. in the pixmap using either the cairo or 
gtk methods
- transfer the pixmap to the pixbuf using gtk.gdk.Pixbuf.get_from_drawable()
- write out the image using gtk.gdk.Pixbuf.save()

John
_______________________________________________
pygtk mailing list   pygtk@daa.com.au
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to