Reputation: 1493
I looked around for a way to load a png into Cairo using Mono (C#) binding of the library but the closest I got was that in C-binding of the library something like cairo_image_surface_create_from_png()
was used. However, in C#-binding of the library I didn't see any useful static members under Cairo.ImageSurface.*
. Somewhere an old article mentioned that the binding is incomplete, is this the case? Currently I'm using Gdk.Image.Pixbuf
to load in-memory (embedded) images but saw that Gtk+ have moved on to Cairo and that Windows.Forms in Mono are using Cairo, I thought the Cairo's C#-binding would at least be completed enough to include image loading. I'm probably missing something?
Upvotes: 1
Views: 2127
Reputation: 7282
I've done this quite recently. You need to load your image into a Cairo Surface:-
var icon = new ImageSurface( pngfile );
Then you can use the ImageSurface.Show method to render it:
icon.Show( ctx, x, y );
See more useful things at the Mono.Cairo Cookbook page.
Upvotes: 2