[Gtk-sharp-list] How can I save a cairo imagesurface as a pixbuf

Christian Hoff christian_hoff at gmx.net
Thu Dec 25 03:58:46 EST 2008


Sorry, forgot to attach the class :-)

Christian Hoff wrote:
> Why don't you use a custom cell renderer? Using a CellRendererPixbuf and 
> converting all your images into a pixbuf takes much more time. I've 
> attached my EAN13Renderer class. It draws the images directly into the 
> graphics context using cairo in the Render() method.
>
> Christian
>
> Andy Selvig wrote:
>   
>> Alan-
>>
>> Try creating a Gtk.DrawingArea, then use Gdk.CairoHelper to create a 
>> Cairo context to draw to. Then you can use Gdk.Pixbuf.FromDrawable to 
>> create the pixbuf. Something like:
>>
>> Gtk.DrawingArea area = new Gtk.DrawingArea();
>> using (Context cr = Gdk.CairoHelper.Create(area.GdkWindow))
>> {
>>
>> }
>>
>>
>> On Mon, Dec 22, 2008 at 11:51 AM, alanb <alan.battersby at ntlworld.com 
>> <mailto:alan.battersby at ntlworld.com>> wrote:
>>
>>
>>     I have a treeview and I want to store dynamically generated images
>>     in one of
>>     its columns.  Reading the treeview tutorial I see that I need my
>>     image as a
>>     pixbuf. I am drawing the images using Cairo, all I can see in the
>>     imagesurface  API is to save as a png file directly with no access
>>     to its
>>     underlying stream which I could use. So how can I convert a Cairo
>>     image to a
>>     pixbuf?
>>
>>     If I use a Gdk.pixmap instead and draw to it, again how do I
>>     convert it to a
>>     pixbuf?
>>
>>     thanks
>>     Alan
>>     

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: EAN13Renderer.cs
Url: http://lists.ximian.com/pipermail/gtk-sharp-list/attachments/20081225/b17dc3a9/attachment.pl 


More information about the Gtk-sharp-list mailing list