[nautilus: 5/18] eel-gdk-pixbuf: use GdkRGBA everywhere



commit 020adaf997cc63a2b78ccb21c34b7f7f5244008e
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Dec 6 15:37:36 2010 +0100

    eel-gdk-pixbuf: use GdkRGBA everywhere

 eel/eel-gdk-pixbuf-extensions.c |   12 +++---------
 eel/eel-gdk-pixbuf-extensions.h |    2 +-
 eel/eel-graphic-effects.c       |   14 ++++++++++----
 eel/eel-graphic-effects.h       |    5 ++---
 4 files changed, 16 insertions(+), 17 deletions(-)
---
diff --git a/eel/eel-gdk-pixbuf-extensions.c b/eel/eel-gdk-pixbuf-extensions.c
index c0d7884..f27340a 100644
--- a/eel/eel-gdk-pixbuf-extensions.c
+++ b/eel/eel-gdk-pixbuf-extensions.c
@@ -185,7 +185,7 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf,
                        guint saturation,
                        guint brightness,
                        guint lighten_value,
-                       guint color)
+                       GdkRGBA *color)
 {
  	GdkPixbuf *temp_pixbuf, *old_pixbuf;
 
@@ -195,17 +195,11 @@ eel_gdk_pixbuf_render (GdkPixbuf *pixbuf,
 	}
 	else if (render_mode == 2) {
 	/* colorize icon */
-		temp_pixbuf = eel_create_colorized_pixbuf (pixbuf,
-				   EEL_RGBA_COLOR_GET_R (color),
-				   EEL_RGBA_COLOR_GET_G (color),
-				   EEL_RGBA_COLOR_GET_B (color));
+		temp_pixbuf = eel_create_colorized_pixbuf (pixbuf, color);
 	} else if (render_mode == 3) {
 	/* monochromely colorize icon */
 		old_pixbuf = eel_create_darkened_pixbuf (pixbuf, 0, 255);		
-		temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf,
-				   EEL_RGBA_COLOR_GET_R (color),
-				   EEL_RGBA_COLOR_GET_G (color),
-				   EEL_RGBA_COLOR_GET_B (color));
+		temp_pixbuf = eel_create_colorized_pixbuf (old_pixbuf, color);
 		g_object_unref (old_pixbuf);
 	} else {
 		temp_pixbuf = NULL;
diff --git a/eel/eel-gdk-pixbuf-extensions.h b/eel/eel-gdk-pixbuf-extensions.h
index 83e9a42..dc93abc 100644
--- a/eel/eel-gdk-pixbuf-extensions.h
+++ b/eel/eel-gdk-pixbuf-extensions.h
@@ -41,6 +41,6 @@ GdkPixbuf *          eel_gdk_pixbuf_render                    (GdkPixbuf *pixbuf
                                                                guint saturation,
                                                                guint brightness,
                                                                guint lighten_value,
-                                                               guint color);
+                                                               GdkRGBA *color);
 
 #endif /* EEL_GDK_PIXBUF_EXTENSIONS_H */
diff --git a/eel/eel-graphic-effects.c b/eel/eel-graphic-effects.c
index 0dc40d2..ad25dd7 100644
--- a/eel/eel-graphic-effects.c
+++ b/eel/eel-graphic-effects.c
@@ -26,7 +26,10 @@
    and selection hilighting */
 
 #include <config.h>
+
 #include "eel-graphic-effects.h"
+#include "eel-glib-extensions.h"
+
 #include <string.h>
 
 /* shared utility to create a new pixbuf from the passed-in one */
@@ -162,9 +165,7 @@ eel_create_darkened_pixbuf (GdkPixbuf *src, int saturation, int darken)
 
 GdkPixbuf *
 eel_create_colorized_pixbuf (GdkPixbuf *src,
-				  int red_value,
-				  int green_value,
-				  int blue_value)
+			     GdkRGBA *color)
 {
 	int i, j;
 	int width, height, has_alpha, src_row_stride, dst_row_stride;
@@ -173,7 +174,8 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
 	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_has_alpha (src)
 			       && gdk_pixbuf_get_n_channels (src) == 3)
@@ -181,6 +183,10 @@ eel_create_colorized_pixbuf (GdkPixbuf *src,
 				  && gdk_pixbuf_get_n_channels (src) == 4), NULL);
 	g_return_val_if_fail (gdk_pixbuf_get_bits_per_sample (src) == 8, NULL);
 
+	red_value = eel_round (color->red * 255);
+	green_value = eel_round (color->green * 255);
+	blue_value = eel_round (color->blue * 255);	
+
 	dest = create_new_pixbuf (src);
 	
 	has_alpha = gdk_pixbuf_get_has_alpha (src);
diff --git a/eel/eel-graphic-effects.h b/eel/eel-graphic-effects.h
index e53beca..b8d8b32 100644
--- a/eel/eel-graphic-effects.h
+++ b/eel/eel-graphic-effects.h
@@ -26,6 +26,7 @@
 #define EEL_GRAPHIC_EFFECTS_H
 
 #include <gdk-pixbuf/gdk-pixbuf.h>
+#include <gdk/gdk.h>
 
 /* return a lightened pixbuf for pre-lighting */
 GdkPixbuf *eel_create_spotlight_pixbuf (GdkPixbuf *source_pixbuf);
@@ -37,9 +38,7 @@ GdkPixbuf *eel_create_darkened_pixbuf  (GdkPixbuf *source_pixbuf,
 
 /* return a pixbuf colorized with the color specified by the parameters */
 GdkPixbuf* eel_create_colorized_pixbuf (GdkPixbuf *source_pixbuf,
-					int        red_value,
-					int        green_value,
-					int        blue_value);
+					GdkRGBA *color);
 
 /* stretch a image frame */
 GdkPixbuf *eel_stretch_frame_image     (GdkPixbuf *frame_image,



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]