rendered paste bodyIndex: f-pixbuf-utils.c
===================================================================
RCS file: /cvs/gnome/f-spot/libfspot/f-pixbuf-utils.c,v
retrieving revision 1.10
diff -u -p -r1.10 f-pixbuf-utils.c
--- f-pixbuf-utils.c 21 Dec 2006 20:47:10 -0000 1.10
+++ f-pixbuf-utils.c 24 Dec 2006 22:52:06 -0000
@@ -372,6 +372,10 @@ f_pixbuf_remove_redeye (GdkPixbuf *src)
int r, g, b;
int channels = gdk_pixbuf_get_n_channels (src);
+ double RED_FACTOR = 0.5133333;
+ double GREEN_FACTOR = 1;
+ double BLUE_FACTOR = 0.1933333;
+ int threshold = -15;
guchar *row = gdk_pixbuf_get_pixels (src);
for (i = 0; i < height; i++) {
@@ -381,9 +385,14 @@ f_pixbuf_remove_redeye (GdkPixbuf *src)
r = *col;
g = *(col + 1);
b = *(col + 2);
-
- if ((r > (3 * g / 2) && r > (3 * b / 2)) || (g > r && b > r)) {
- memset(col, (r * 31 + g * 61 + b * 8) / 100, 3);
+
+ int adjusted_red = r * RED_FACTOR;
+ int adjusted_green = g * GREEN_FACTOR;
+ int adjusted_blue = b * BLUE_FACTOR;
+ if (adjusted_red >= adjusted_green - threshold
+ && adjusted_red >= adjusted_blue - threshold)
+ {
+ memset(col, ((double)(adjusted_green + adjusted_blue)) / (2.0 * RED_FACTOR) , 3);
}
col += channels;