summaryrefslogtreecommitdiff
path: root/eel
diff options
context:
space:
mode:
authorErnestas Kulik <ernestask@gnome.org>2018-05-23 12:54:43 +0300
committerErnestas Kulik <ernestask@gnome.org>2018-05-30 11:39:13 +0300
commit487213ad9b7b1f216ce9f9e9d6aecf5b51a6ea19 (patch)
tree173d484312a047af37233f413cbea7c75b905094 /eel
parentad18383afda425822615c5939178e072faf01a78 (diff)
downloadnautilus-487213ad9b7b1f216ce9f9e9d6aecf5b51a6ea19.tar.gz
canvas-item: Drop gtk_style_context_get_background_color()
Even though more convoluted than the previous solution, this one should last longer. Canvas item icons are now colorized by first drawing the background to a Cairo surface and then multiplying the color values of the original icon pixbuf and the ones from the newly created one.
Diffstat (limited to 'eel')
-rw-r--r--eel/eel-graphic-effects.c29
-rw-r--r--eel/eel-graphic-effects.h2
2 files changed, 17 insertions, 14 deletions
diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c
index b3fdc5bdb..4204e8825 100644
--- a/eel/eel-graphic-effects.c
+++ b/eel/eel-graphic-effects.c
@@ -105,11 +105,11 @@ eel_create_spotlight_pixbuf (GdkPixbuf *src)
return dest;
}
-/* this routine colorizes the passed-in pixbuf by multiplying each pixel with the passed in color */
+/* This routine colorizes %src by multiplying each pixel with colors in %dest. */
GdkPixbuf *
eel_create_colorized_pixbuf (GdkPixbuf *src,
- GdkRGBA *color)
+ GdkPixbuf *dest)
{
int i, j;
int width, height, has_alpha, src_row_stride, dst_row_stride;
@@ -117,21 +117,21 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
guchar *original_pixels;
guchar *pixsrc;
guchar *pixdest;
- GdkPixbuf *dest;
- gint red_value, green_value, blue_value;
g_return_val_if_fail (gdk_pixbuf_get_colorspace (src) == GDK_COLORSPACE_RGB, NULL);
+ g_return_val_if_fail (gdk_pixbuf_get_colorspace (dest) == GDK_COLORSPACE_RGB, NULL);
+
g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (src)
&& gdk_pixbuf_get_n_channels (src) == 3)
|| (gdk_pixbuf_get_has_alpha (src)
&& gdk_pixbuf_get_n_channels (src) == 4), NULL);
- g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
+ g_return_val_if_fail ((!gdk_pixbuf_get_has_alpha (dest)
+ && gdk_pixbuf_get_n_channels (dest) == 3)
+ || (gdk_pixbuf_get_has_alpha (dest)
+ && gdk_pixbuf_get_n_channels (dest) == 4), NULL);
- red_value = (gint) floor (color->red * 255);
- green_value = (gint) floor (color->green * 255);
- blue_value = (gint) floor (color->blue * 255);
-
- dest = create_new_pixbuf (src);
+ g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
+ g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (dest) == 8, NULL);
has_alpha = gdk_pixbuf_get_has_alpha (src);
width = gdk_pixbuf_get_width (src);
@@ -147,9 +147,12 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
pixsrc = original_pixels + i * src_row_stride;
for (j = 0; j < width; j++)
{
- *pixdest++ = (*pixsrc++ *red_value) >> 8;
- *pixdest++ = (*pixsrc++ *green_value) >> 8;
- *pixdest++ = (*pixsrc++ *blue_value) >> 8;
+ *pixdest = (*pixsrc++ * *pixdest) >> 8;
+ pixdest++;
+ *pixdest = (*pixsrc++ * *pixdest) >> 8;
+ pixdest++;
+ *pixdest = (*pixsrc++ * *pixdest) >> 8;
+ pixdest++;
if (has_alpha)
{
*pixdest++ = *pixsrc++;
diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h
index b67a754a3..67de5f7cc 100644
--- a/eel/eel-graphic-effects.h
+++ b/eel/eel-graphic-effects.h
@@ -29,4 +29,4 @@ GdkPixbuf *eel_create_spotlight_pixbuf (GdkPixbuf *source_pixbuf);
/* return a pixbuf colorized with the color specified by the parameters */
GdkPixbuf* eel_create_colorized_pixbuf (GdkPixbuf *source_pixbuf,
- GdkRGBA *color); \ No newline at end of file
+ GdkPixbuf *dest);