[gthumb] fixed CAIRO_SET_RGBA and CAIRO_GET_RGBA



commit be543e030dae8c275bf32c98715bc24b8c02b717
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Feb 5 19:48:07 2015 +0100

    fixed CAIRO_SET_RGBA and CAIRO_GET_RGBA

 extensions/cairo_io/cairo-image-surface-tiff.c     |    2 +-
 extensions/cairo_io/gth-image-saver-webp.c         |    2 +-
 extensions/file_tools/cairo-effects.c              |    2 +-
 .../file_tools/gth-file-tool-adjust-colors.c       |    2 +-
 .../file_tools/gth-file-tool-adjust-contrast.c     |    2 +-
 extensions/file_tools/gth-file-tool-curves.c       |    2 +-
 extensions/file_tools/gth-file-tool-effects.c      |    3 +--
 extensions/file_tools/gth-file-tool-grayscale.c    |    2 +-
 extensions/file_tools/gth-file-tool-negative.c     |    2 +-
 gthumb/cairo-utils.c                               |    7 +++++--
 gthumb/cairo-utils.h                               |   16 +++++++++-------
 gthumb/gimp-op.h                                   |    3 +--
 gthumb/gth-histogram.c                             |    2 +-
 13 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/extensions/cairo_io/cairo-image-surface-tiff.c b/extensions/cairo_io/cairo-image-surface-tiff.c
index 2ffbfef..7160e7d 100644
--- a/extensions/cairo_io/cairo-image-surface-tiff.c
+++ b/extensions/cairo_io/cairo-image-surface-tiff.c
@@ -268,7 +268,7 @@ _cairo_image_surface_create_from_tiff (GInputStream  *istream,
        if (TIFFReadRGBAImageOriented (tif, image_width, image_height, raster, orientation, 0)) {
                guchar *surface_row;
                int     line_step;
-               int     x, y;
+               int     x, y, temp;
                guchar  r, g, b, a;
                uint32 *src_pixel;
 
diff --git a/extensions/cairo_io/gth-image-saver-webp.c b/extensions/cairo_io/gth-image-saver-webp.c
index 853b3b1..307020e 100644
--- a/extensions/cairo_io/gth-image-saver-webp.c
+++ b/extensions/cairo_io/gth-image-saver-webp.c
@@ -126,7 +126,7 @@ _WebPPictureImportCairoSurface (WebPPicture     *const picture,
        int       stride;
        guchar   *src_row;
        uint32_t *dest_row;
-       int       y, x;
+       int       y, x, temp;
        guchar    r, g, b, a;
 
        if (_cairo_image_surface_get_has_alpha (image))
diff --git a/extensions/file_tools/cairo-effects.c b/extensions/file_tools/cairo-effects.c
index 69413e2..209241a 100644
--- a/extensions/file_tools/cairo-effects.c
+++ b/extensions/file_tools/cairo-effects.c
@@ -36,7 +36,7 @@ cairo_image_surface_apply_curves (cairo_surface_t  *source,
        int              height;
        int              source_stride;
        unsigned char   *p_source_line;
-       int              x, y;
+       int              x, y, temp;
        gboolean         cancelled = FALSE;
        double           progress;
        unsigned char   *p_source;
diff --git a/extensions/file_tools/gth-file-tool-adjust-colors.c 
b/extensions/file_tools/gth-file-tool-adjust-colors.c
index d825bb0..cb683ab 100644
--- a/extensions/file_tools/gth-file-tool-adjust-colors.c
+++ b/extensions/file_tools/gth-file-tool-adjust-colors.c
@@ -115,7 +115,7 @@ adjust_colors_exec (GthAsyncTask *task,
        unsigned char   *p_destination;
        gboolean         cancelled;
        double           progress;
-       int              x, y;
+       int              x, y, temp;
        unsigned char    values[4];
        int              channel;
        unsigned char    value;
diff --git a/extensions/file_tools/gth-file-tool-adjust-contrast.c 
b/extensions/file_tools/gth-file-tool-adjust-contrast.c
index bb30c36..41931f0 100644
--- a/extensions/file_tools/gth-file-tool-adjust-contrast.c
+++ b/extensions/file_tools/gth-file-tool-adjust-contrast.c
@@ -252,7 +252,7 @@ adjust_contrast_exec (GthAsyncTask *task,
        unsigned char   *p_destination;
        gboolean         cancelled;
        double           progress;
-       int              x, y;
+       int              x, y, temp;
        unsigned char    red, green, blue, alpha;
 
        /* initialize the extra data */
diff --git a/extensions/file_tools/gth-file-tool-curves.c b/extensions/file_tools/gth-file-tool-curves.c
index e224e2c..d2f0b8a 100644
--- a/extensions/file_tools/gth-file-tool-curves.c
+++ b/extensions/file_tools/gth-file-tool-curves.c
@@ -126,7 +126,7 @@ curves_exec (GthAsyncTask *task,
        unsigned char   *p_destination;
        gboolean         cancelled;
        double           progress;
-       int              x, y;
+       int              x, y, temp;
        unsigned char    red, green, blue, alpha;
 
        /* initialize the extra data */
diff --git a/extensions/file_tools/gth-file-tool-effects.c b/extensions/file_tools/gth-file-tool-effects.c
index 8571780..dc02d01 100644
--- a/extensions/file_tools/gth-file-tool-effects.c
+++ b/extensions/file_tools/gth-file-tool-effects.c
@@ -809,12 +809,11 @@ blurred_edges_exec (GthAsyncTask *task,
        unsigned char   *p_source_line;
        unsigned char   *p_destination_line;
        unsigned char   *p_blurred_line;
-       int              x, y;
+       int              x, y, temp;
        double           progress;
        unsigned char   *p_source;
        unsigned char   *p_destination;
        unsigned char   *p_blurred;
-       unsigned char    temp;
        unsigned char    image_red, image_green, image_blue, image_alpha;
        unsigned char    layer_red, layer_green, layer_blue, layer_alpha;
        gboolean         cancelled = FALSE;
diff --git a/extensions/file_tools/gth-file-tool-grayscale.c b/extensions/file_tools/gth-file-tool-grayscale.c
index 0680350..9a45bff 100644
--- a/extensions/file_tools/gth-file-tool-grayscale.c
+++ b/extensions/file_tools/gth-file-tool-grayscale.c
@@ -87,7 +87,7 @@ grayscale_exec (GthAsyncTask *task,
        unsigned char   *p_destination;
        gboolean         cancelled;
        double           progress;
-       int              x, y;
+       int              x, y, temp;
        unsigned char    red, green, blue, alpha;
        unsigned char    min, max, value;
 
diff --git a/extensions/file_tools/gth-file-tool-negative.c b/extensions/file_tools/gth-file-tool-negative.c
index 7d7f65d..7beda21 100644
--- a/extensions/file_tools/gth-file-tool-negative.c
+++ b/extensions/file_tools/gth-file-tool-negative.c
@@ -41,7 +41,7 @@ negative_exec (GthAsyncTask *task,
        unsigned char   *p_destination;
        gboolean         cancelled;
        double           progress;
-       int              x, y;
+       int              x, y, temp;
        unsigned char    red, green, blue, alpha;
 
        source = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
diff --git a/gthumb/cairo-utils.c b/gthumb/cairo-utils.c
index 2393264..6af4de1 100644
--- a/gthumb/cairo-utils.c
+++ b/gthumb/cairo-utils.c
@@ -641,7 +641,7 @@ _cairo_image_surface_color_shift (cairo_surface_t *image,
        int              width, height, src_stride, dest_stride;
        guchar          *src_pixels, *src_row, *src_pixel;
        guchar          *dest_pixels, *dest_row, *dest_pixel;
-       int              val;
+       int              val, temp;
        guchar           r, g, b, a;
 
        shifted = _cairo_image_surface_create_compatible (image);
@@ -696,6 +696,8 @@ _cairo_copy_line_as_rgba_big_endian (guchar *dest,
        guint x;
 
        if (alpha) {
+               int temp;
+
                for (x = 0; x < width; x++) {
                        CAIRO_GET_RGBA (src, dest[0], dest[1], dest[2], dest[3]);
 
@@ -723,7 +725,8 @@ _cairo_copy_line_as_rgba_little_endian (guchar *dest,
        guint x;
 
        if (alpha) {
-               int r, g, b, a;
+               int r, g, b, a, temp;
+
                for (x = 0; x < width; x++) {
                        CAIRO_GET_RGBA (src, r, g, b, a);
                        dest[0] = b;
diff --git a/gthumb/cairo-utils.h b/gthumb/cairo-utils.h
index 85efc31..c83d3b2 100644
--- a/gthumb/cairo-utils.h
+++ b/gthumb/cairo-utils.h
@@ -29,7 +29,9 @@
 #include "typedefs.h"
 
 
-#define CAIRO_MAX_IMAGE_SIZE 32767
+#define CAIRO_MAX_IMAGE_SIZE    32767
+#define CLAMP_TEMP(x, min, max) (temp = (x), CLAMP (temp, min, max))
+#define CLAMP_PIXEL(x)          CLAMP_TEMP (x, 0, 255)
 
 #if G_BYTE_ORDER == G_LITTLE_ENDIAN /* BGRA */
 
@@ -72,9 +74,9 @@
                }                                                               \
                else {                                                          \
                        double factor = (double) pixel[CAIRO_ALPHA] / 0xff;     \
-                       pixel[CAIRO_RED] = factor * (red);                      \
-                       pixel[CAIRO_GREEN] = factor * (green);                  \
-                       pixel[CAIRO_BLUE] = factor * (blue);                    \
+                       pixel[CAIRO_RED] = CLAMP_PIXEL (factor * (red));        \
+                       pixel[CAIRO_GREEN] = CLAMP_PIXEL (factor * (green));    \
+                       pixel[CAIRO_BLUE] = CLAMP_PIXEL (factor * (blue));      \
                }                                                               \
        } G_STMT_END
 
@@ -95,9 +97,9 @@
                }                                                               \
                else {                                                          \
                        double factor = (double) 0xff / alpha;                  \
-                       red = factor * pixel[CAIRO_RED];                        \
-                       green = factor * pixel[CAIRO_GREEN];                    \
-                       blue = factor * pixel[CAIRO_BLUE];                      \
+                       red = CLAMP_PIXEL (factor * pixel[CAIRO_RED]);          \
+                       green = CLAMP_PIXEL (factor * pixel[CAIRO_GREEN]);      \
+                       blue = CLAMP_PIXEL (factor * pixel[CAIRO_BLUE]);        \
                }                                                               \
        } G_STMT_END
 
diff --git a/gthumb/gimp-op.h b/gthumb/gimp-op.h
index 699437d..e97fcc7 100644
--- a/gthumb/gimp-op.h
+++ b/gthumb/gimp-op.h
@@ -24,6 +24,7 @@
 
 #include <config.h>
 #include <glib.h>
+#include "cairo-utils.h"
 
 /* Optimizations taken from xcftools 1.0.7 written by Henning Makholm
  *
@@ -33,9 +34,7 @@
  * */
 
 #define ADD_ALPHA(v, a)                        (add_alpha_table[v][a])
-#define CLAMP_TEMP(x, min, max)                (temp = (x), CLAMP (temp, min, max))
 #define ABS_TEMP2(x)                   (temp2 = (x), (temp2 < 0) ? -temp2: temp2)
-#define CLAMP_PIXEL(x)                 CLAMP_TEMP (x, 0, 255)
 #define GIMP_OP_NORMAL(xL, xI, aL)     CLAMP_PIXEL (ADD_ALPHA (xL, aL) + ADD_ALPHA (xI, 255 - aL))
 #define GIMP_OP_LIGHTEN_ONLY(xL, xI)   MAX (xI, xL)
 #define GIMP_OP_SCREEN(xL, xI)         CLAMP_PIXEL (255 ^ ADD_ALPHA (255 - xI, 255 - xL))
diff --git a/gthumb/gth-histogram.c b/gthumb/gth-histogram.c
index ae4da47..75d7624 100644
--- a/gthumb/gth-histogram.c
+++ b/gthumb/gth-histogram.c
@@ -144,7 +144,7 @@ gth_histogram_calculate_for_image (GthHistogram    *self,
        int      width, height, has_alpha;
        int      rowstride;
        guchar  *line, *pixel;
-       int      i, j, value;
+       int      i, j, value, temp;
        guchar   red, green, blue, alpha;
 
        g_return_if_fail (GTH_IS_HISTOGRAM (self));


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