Hi all:
How can I render an emblemedIcon into a cairo surface, or into a Gdk.Pixbuf, to paint it into a drawingArea or similar?
If it is not possible, is it possible to create a transparent button with an icon inside?
Thanks.
Hi all:
How can I render an emblemedIcon into a cairo surface, or into a Gdk.Pixbuf, to paint it into a drawingArea or similar?
If it is not possible, is it possible to create a transparent button with an icon inside?
Thanks.
A GEmblemedIcon
is a GIcon
plus a list of GEmblem
instances, which are a subclass of GIcon
. This means that, to render a GEmblemedIcon
you’d use the same code you use for any other GIcon
, plus you’ll have to go through every single emblem and decide where to draw it.
GTK has API to do that as part of the GtkIconInfo
class; to get a GdkPixbuf
out of any GIcon
, including emblemed icons, you can use:
And to turn a GdkPixbuf
into a cairo_surface_t
that you can then use as a source for drawing on a Cairo context, you can use gdk_cairo_surface_create_from_pixbuf()
.
Alternatively, you can use gtk_icon_info_load_surface()
and bypass the GdkPixbuf
step entirely.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.