Re: Bitmap transparency
- From: xapantu <xapantu gmail com>
- To: goocanvas-list gnome org
- Subject: Re: Bitmap transparency
- Date: Wed, 08 Dec 2010 21:43:20 +0100
Hi,
Any chance for another release for the 0.x serie ? We need it for gtk2,
we won't use gtk3 until the summer :)
And, if no, can we release a patched version in our ppa ?
(ppa:ella-animation/dev)
I have just managed to start making the patch, it is quite small. It
isn't finished, I need to update the documentation (and the examples),
and it is for goocanvas-0.15. I am going to install gtk3 tomorrow to
test with the master branch but I think it should work.
--xapantu
--- ../../goocanvas-0.15/src/goocanvasimage.c 2009-06-29
15:10:09.000000000 +0200
+++ src/goocanvasimage.c 2010-12-08 21:20:46.289732403 +0100
@@ -53,6 +53,7 @@
PROP_WIDTH,
PROP_HEIGHT,
PROP_SCALE_TO_FIT,
+ PROP_ALPHA,
/* Convenience properties. */
PROP_PIXBUF
@@ -116,6 +117,7 @@
0.0, G_MAXDOUBLE, 0.0,
G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_class, PROP_SCALE_TO_FIT,
g_param_spec_boolean
("scale-to-fit",
_("Scale To Fit"),
@@ -123,12 +125,20 @@
FALSE,
G_PARAM_READWRITE));
+ g_object_class_install_property (gobject_class, PROP_ALPHA,
+ g_param_spec_double ("alpha",
+ _("Alpha"),
+ _("The opacity of the image"),
+ 0.0, G_MAXDOUBLE, 0.0,
+ G_PARAM_READWRITE));
+
g_object_class_install_property (gobject_class, PROP_PIXBUF,
g_param_spec_object ("pixbuf",
_("Pixbuf"),
_("The GdkPixbuf to display"),
GDK_TYPE_PIXBUF,
G_PARAM_WRITABLE));
+
}
@@ -335,6 +345,9 @@
case PROP_WIDTH:
image_data->width = g_value_get_double (value);
break;
+ case PROP_ALPHA:
+ image_data->alpha = g_value_get_double (value);
+ break;
case PROP_HEIGHT:
image_data->height = g_value_get_double (value);
break;
@@ -421,6 +434,7 @@
cairo_surface_t *surface;
gdouble width, height;
+ //cairo_paint_with_alpha(cr, 0.1);
if (!image_data->pattern)
return;
@@ -445,7 +459,10 @@
cairo_set_source (cr, image_data->pattern);
cairo_rectangle (cr, image_data->x, image_data->y,
image_data->width, image_data->height);
- cairo_fill (cr);
+ if(image_data->alpha != 1.0)
+ cairo_paint_with_alpha (cr, image_data->alpha);
+ else
+ cairo_fill (cr);
#else
/* Using cairo_paint() used to be much slower than cairo_fill(),
though
they seem similar now. I'm not sure if it matters which we use. */
Le mardi 07 décembre 2010 à 22:33 +0000, Damon Chaplin a écrit :
> On Tue, 2010-12-07 at 19:17 +0100, xapantu wrote:
> > Hi,
> >
> > I would like to know if I could set a custom opacity value for bitmap ?
> > I can't find it in the api reference...
> >
> > And if it is not (yet) implemented, maybe I can do a patch ? You agree
> > to include it in a next version of GooCanvas ? (because I don't want to
> > ask to the user to patch GooCanvas ^^).
> >
> > I am a developer of Ella (http://ella.tuxfamily.org) and we really need
> > this feature ^^.
>
> No, I don't think there is a way to set the opacity of a bitmap at
> present. I guess you could use cairo_paint_with_alpha() to do that.
>
> A patch would be welcome, as long as it isn't too complicated.
>
> Or you could write your own custom item.
>
>
> > Thanks for all your work, GooCanvas is definitively awesome!
>
> Thanks,
>
> Damon
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]