[gthumb] special effects: added other effects



commit b78e49f40d70163af35b525f6b202c29b4ab1787
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Thu Jan 15 12:08:01 2015 +0100

    special effects: added other effects

 extensions/file_tools/cairo-effects.c         |   13 +-
 extensions/file_tools/cairo-effects.h         |    1 +
 extensions/file_tools/gth-file-tool-effects.c |  373 ++++++++++++++++++++++---
 extensions/file_tools/gth-file-tool-effects.h |   17 +-
 extensions/file_tools/gth-file-tool-lomo.c    |    2 +-
 extensions/file_tools/main.c                  |   24 +-
 6 files changed, 366 insertions(+), 64 deletions(-)
---
diff --git a/extensions/file_tools/cairo-effects.c b/extensions/file_tools/cairo-effects.c
index 63d710a..69413e2 100644
--- a/extensions/file_tools/cairo-effects.c
+++ b/extensions/file_tools/cairo-effects.c
@@ -91,6 +91,7 @@ cairo_image_surface_apply_curves (cairo_surface_t  *source,
 gboolean
 cairo_image_surface_apply_vignette (cairo_surface_t  *source,
                                    GthCurve        **curve,
+                                   guchar            vignette_alpha,
                                    GthAsyncTask     *task)
 {
        gboolean         local_curves;
@@ -115,7 +116,7 @@ cairo_image_surface_apply_vignette (cairo_surface_t  *source,
        local_curves = (curve == NULL);
        if (local_curves) {
                curve = g_new (GthCurve *, GTH_HISTOGRAM_N_CHANNELS);
-               curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 
152,103, 255,255);
+               curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 
158,95, /*152,103,*/ 255,255);
                curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
                curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
                curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
@@ -137,14 +138,13 @@ cairo_image_surface_apply_vignette (cairo_surface_t  *source,
 
        center_x = width / 2.0;
        center_y = height / 2.0;
-       max_d = 2 * sqrt (SQR (center_x) + SQR (center_y));
 
        {
                double a = MAX (width, height) / 2.0;
                double b = MIN (height, width) / 2.0;
 
-               a = a - (a / 10);
-               b = b - (b / 10);
+               a = a - (a / 1.5);
+               b = b - (b / 1.5);
 
                double e = sqrt (1.0 - SQR (b) / SQR (a));
                double c = a * e;
@@ -162,6 +162,10 @@ cairo_image_surface_apply_vignette (cairo_surface_t  *source,
                        f2.x = center_x;
                        f2.y = center_y + c;
                }
+
+               p.x = 0;
+               p.y = 0;
+               max_d = gth_point_distance (&p, &f1) + gth_point_distance (&p, &f2);
        }
 
        p_source_line = _cairo_image_surface_flush_and_get_data (source);
@@ -188,6 +192,7 @@ cairo_image_surface_apply_vignette (cairo_surface_t  *source,
                                        alpha = 255 * ((d - min_d) / (max_d - min_d));
                                else
                                        alpha = 255;
+                               alpha = ADD_ALPHA (alpha, vignette_alpha);
 
                                p_source[CAIRO_RED] = GIMP_OP_NORMAL (red, image_red, alpha);
                                p_source[CAIRO_GREEN] = GIMP_OP_NORMAL (green, image_green, alpha);
diff --git a/extensions/file_tools/cairo-effects.h b/extensions/file_tools/cairo-effects.h
index 0a5dec2..146317a 100644
--- a/extensions/file_tools/cairo-effects.h
+++ b/extensions/file_tools/cairo-effects.h
@@ -34,6 +34,7 @@ gboolean cairo_image_surface_apply_curves     (cairo_surface_t  *source,
                                                 GthAsyncTask     *task);
 gboolean cairo_image_surface_apply_vignette    (cairo_surface_t  *source,
                                                 GthCurve        **curve,
+                                                guchar            vignette_alpha,
                                                 GthAsyncTask     *task);
 gboolean cairo_image_surface_apply_bcs         (cairo_surface_t  *source,
                                                 double            brightness,
diff --git a/extensions/file_tools/gth-file-tool-effects.c b/extensions/file_tools/gth-file-tool-effects.c
index a93cdb0..0b02da5 100644
--- a/extensions/file_tools/gth-file-tool-effects.c
+++ b/extensions/file_tools/gth-file-tool-effects.c
@@ -449,17 +449,16 @@ cooler_add_to_special_effects (GthFilterGrid *grid)
 }
 
 
-/* -- Instagram -- */
+/* -- Soil -- */
 
 
 static gpointer
-instagram_exec (GthAsyncTask *task,
-               gpointer      user_data)
+soil_exec (GthAsyncTask *task,
+          gpointer      user_data)
 {
        cairo_surface_t *original;
        cairo_surface_t *source;
        GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
-       gboolean         cancelled = FALSE;
 
        original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
        source = _cairo_image_surface_copy (original);
@@ -468,10 +467,10 @@ instagram_exec (GthAsyncTask *task,
        curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 75,83, 198,185, 
255,255);
        curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 70,63, 
184,189, 255,255);
        curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 76,74, 
191,176, 255,255);
-       cancelled = ! cairo_image_surface_apply_curves (source, curve, task);
-       if (! cancelled) {
-               cancelled = ! cairo_image_surface_apply_vignette (source, NULL, task);
-               if (! cancelled)
+
+       if (cairo_image_surface_apply_curves (source, curve, task)
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
+       {
                        gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
        }
 
@@ -487,39 +486,87 @@ instagram_exec (GthAsyncTask *task,
 
 
 void
-instagram_add_to_special_effects (GthFilterGrid *grid)
+soil_add_to_special_effects (GthFilterGrid *grid)
 {
        gth_filter_grid_add_filter (grid,
                                    GTH_FILTER_GRID_NEW_FILTER_ID,
-                                   gth_image_task_new (_("Applying changes"), NULL, instagram_exec, NULL, 
NULL, NULL),
-                                   _("Instagram"),
+                                   gth_image_task_new (_("Applying changes"), NULL, soil_exec, NULL, NULL, 
NULL),
+                                   "Soil",
                                    NULL);
 }
 
 
-/* -- Cherry -- */
+/* -- Desert -- */
 
 
 static gpointer
-cherry_exec (GthAsyncTask *task,
+desert_exec (GthAsyncTask *task,
             gpointer      user_data)
 {
        cairo_surface_t *original;
        cairo_surface_t *source;
        GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
-       gboolean         cancelled = FALSE;
+
+       original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       source = _cairo_image_surface_copy (original);
+
+       curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 115,145, 
255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 71,66, 208,204, 
255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 71,55, 
200,206, 255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 232,185, 
255,248);
+
+       if (cairo_image_surface_apply_curves (source, curve, task)
+           && cairo_image_surface_apply_bcs (source, 0, 0, 20.0 / 100, task)
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
+       {
+                       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
+       }
+
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_BLUE]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_GREEN]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_RED]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_VALUE]);
+       cairo_surface_destroy (source);
+       cairo_surface_destroy (original);
+
+       return NULL;
+}
+
+
+void
+desert_add_to_special_effects (GthFilterGrid *grid)
+{
+       gth_filter_grid_add_filter (grid,
+                                   GTH_FILTER_GRID_NEW_FILTER_ID,
+                                   gth_image_task_new (_("Applying changes"), NULL, desert_exec, NULL, NULL, 
NULL),
+                                   "Desert",
+                                   NULL);
+}
+
+
+/* -- Artic -- */
+
+
+static gpointer
+artic_exec (GthAsyncTask *task,
+           gpointer      user_data)
+{
+       cairo_surface_t *original;
+       cairo_surface_t *source;
+       GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
 
        original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
        source = _cairo_image_surface_copy (original);
 
        curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
-       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,12, 74,79, 
134,156, 188,209, 239,255);
-       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 12,0, 78,67, 
138,140, 189,189, 252,233);
-       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,8, 77,100, 
139,140, 202,186, 255,244);
+       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 133,122, 
255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 64,57, 
176,186, 255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 180,207, 
255,255);
+
        if (cairo_image_surface_apply_curves (source, curve, task)
-           && cairo_image_surface_apply_vignette (source, NULL, task))
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
        {
-               gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
+                       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
        }
 
        g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_BLUE]);
@@ -534,12 +581,59 @@ cherry_exec (GthAsyncTask *task,
 
 
 void
-cherry_add_to_special_effects (GthFilterGrid *grid)
+artic_add_to_special_effects (GthFilterGrid *grid)
 {
        gth_filter_grid_add_filter (grid,
                                    GTH_FILTER_GRID_NEW_FILTER_ID,
-                                   gth_image_task_new (_("Applying changes"), NULL, cherry_exec, NULL, NULL, 
NULL),
-                                   _("Cherry"),
+                                   gth_image_task_new (_("Applying changes"), NULL, artic_exec, NULL, NULL, 
NULL),
+                                   "Artic",
+                                   NULL);
+}
+
+
+/* -- Mangos -- */
+
+
+static gpointer
+mangos_exec (GthAsyncTask *task,
+            gpointer      user_data)
+{
+       cairo_surface_t *original;
+       cairo_surface_t *source;
+       GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
+
+       original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       source = _cairo_image_surface_copy (original);
+
+       curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
+       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,0, 75,67, 135,155, 
171,193, 252,255);
+       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 84,65, 
162,167, 255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 84,74, 
160,150, 255,255);
+
+       if (cairo_image_surface_apply_curves (source, curve, task)
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
+       {
+                       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
+       }
+
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_BLUE]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_GREEN]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_RED]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_VALUE]);
+       cairo_surface_destroy (source);
+       cairo_surface_destroy (original);
+
+       return NULL;
+}
+
+
+void
+mangos_add_to_special_effects (GthFilterGrid *grid)
+{
+       gth_filter_grid_add_filter (grid,
+                                   GTH_FILTER_GRID_NEW_FILTER_ID,
+                                   gth_image_task_new (_("Applying changes"), NULL, mangos_exec, NULL, NULL, 
NULL),
+                                   "Mangos",
                                    NULL);
 }
 
@@ -548,38 +642,70 @@ cherry_add_to_special_effects (GthFilterGrid *grid)
 
 
 static gpointer
-grapes_exec (GthAsyncTask *task,
+fresh_blue_exec (GthAsyncTask *task,
                 gpointer      user_data)
 {
        cairo_surface_t *original;
        cairo_surface_t *source;
        GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
-       gboolean         cancelled = FALSE;
 
        original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
        source = _cairo_image_surface_copy (original);
 
-       /*
-       curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 126,138, 
255,255);
-       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 78,41, 145,142, 
230,233);
-       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,4, 40,34, 
149,145, 255,255);
-       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
-       */
+       curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 95,61, 
116,71, 255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 81,94, 96,125, 
255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 75,107, 
86,129, 255,255);
+       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,0, 39,139, 
58,168, 255,255);
+
+       if (cairo_image_surface_apply_curves (source, curve, task)
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
+       {
+                       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
+       }
+
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_BLUE]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_GREEN]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_RED]);
+       g_object_unref (curve[GTH_HISTOGRAM_CHANNEL_VALUE]);
+       cairo_surface_destroy (source);
+       cairo_surface_destroy (original);
+
+       return NULL;
+}
+
+
+void
+fresh_blue_add_to_special_effects (GthFilterGrid *grid)
+{
+       gth_filter_grid_add_filter (grid,
+                                   GTH_FILTER_GRID_NEW_FILTER_ID,
+                                   gth_image_task_new (_("Applying changes"), NULL, fresh_blue_exec, NULL, 
NULL, NULL),
+                                   "Fresh Blue",
+                                   NULL);
+}
+
+
+/* -- Cherry -- */
+
+
+static gpointer
+cherry_exec (GthAsyncTask *task,
+            gpointer      user_data)
+{
+       cairo_surface_t *original;
+       cairo_surface_t *source;
+       GthCurve        *curve[GTH_HISTOGRAM_N_CHANNELS];
+       gboolean         cancelled = FALSE;
 
-       /*
-       curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 126,137, 
255,255);
-       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,8, 47,32, 207,223, 
255,244);
-       curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 4, 0,4, 40,34, 
149,145, 255,255);
-       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 3, 0,0, 119,137, 
255,255);
-       */
+       original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       source = _cairo_image_surface_copy (original);
 
        curve[GTH_HISTOGRAM_CHANNEL_VALUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 0);
-       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,8, 77,100, 
139,140, 202,186, 255,244);
+       curve[GTH_HISTOGRAM_CHANNEL_RED] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,12, 74,79, 
134,156, 188,209, 239,255);
        curve[GTH_HISTOGRAM_CHANNEL_GREEN] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 12,0, 78,67, 
138,140, 189,189, 252,233);
-       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,12, 74,79, 
134,156, 188,209, 239,255);
-
+       curve[GTH_HISTOGRAM_CHANNEL_BLUE] = gth_curve_new_for_points (GTH_TYPE_BEZIER, 5, 0,8, 77,100, 
139,140, 202,186, 255,244);
        if (cairo_image_surface_apply_curves (source, curve, task)
-           && cairo_image_surface_apply_vignette (source, NULL, task))
+           && cairo_image_surface_apply_vignette (source, NULL, 127, task))
        {
                gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
        }
@@ -596,17 +722,17 @@ grapes_exec (GthAsyncTask *task,
 
 
 void
-grapes_add_to_special_effects (GthFilterGrid *grid)
+cherry_add_to_special_effects (GthFilterGrid *grid)
 {
        gth_filter_grid_add_filter (grid,
                                    GTH_FILTER_GRID_NEW_FILTER_ID,
-                                   gth_image_task_new (_("Applying changes"), NULL, grapes_exec, NULL, NULL, 
NULL),
-                                   _("Grapes"),
+                                   gth_image_task_new (_("Applying changes"), NULL, cherry_exec, NULL, NULL, 
NULL),
+                                   _("Cherry"),
                                    NULL);
 }
 
 
-/**/
+/* -- Vintage -- */
 
 
 static gpointer
@@ -628,7 +754,7 @@ vintage_exec (GthAsyncTask *task,
 
        if (cairo_image_surface_colorize (source, 112, 66, 20, 255, task)
            && cairo_image_surface_apply_bcs (source, 0, -20 / 100, -20 / 100, task)
-           && cairo_image_surface_apply_vignette (source, curve, task))
+           && cairo_image_surface_apply_vignette (source, curve, 255, task))
        {
                        gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), source);
        }
@@ -653,3 +779,160 @@ vintage_add_to_special_effects (GthFilterGrid *grid)
                                    _("Vintage"),
                                    NULL);
 }
+
+
+/* -- Blurred Edges -- */
+
+
+static gpointer
+blurred_edges_exec (GthAsyncTask *task,
+                   gpointer      user_data)
+{
+       cairo_surface_t *original;
+       cairo_surface_t *source;
+       cairo_surface_t *blurred;
+       int              blurred_stride;
+       double           center_x, center_y, min_radius, d, max_radius, max_distance;
+       int              width;
+       int              height;
+       cairo_format_t   format;
+       int              source_stride;
+       cairo_surface_t *destination;
+       int              destination_stride;
+       unsigned char   *p_source_line;
+       unsigned char   *p_destination_line;
+       unsigned char   *p_blurred_line;
+       int              x, y;
+       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;
+
+       gimp_op_init ();
+
+       original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       source = _cairo_image_surface_copy (original);
+
+       blurred = _cairo_image_surface_copy (source);
+       blurred_stride = cairo_image_surface_get_stride (blurred);
+       if (! _cairo_image_surface_blur (blurred, 2, task)) {
+               cairo_surface_destroy (blurred);
+               cairo_surface_destroy (source);
+               return NULL;
+       }
+
+       width = cairo_image_surface_get_width (source);
+       height = cairo_image_surface_get_height (source);
+       format = cairo_image_surface_get_format (source);
+       source_stride = cairo_image_surface_get_stride (source);
+
+       center_x = width / 2.0;
+       center_y = height / 2.0;
+       min_radius = MIN (width, height) / 2.0;
+       min_radius -= min_radius * 0.5;
+       max_radius = MAX (width, height) / 2.0 /*sqrt (SQR (center_x) + SQR (center_y))*/;
+       max_distance = max_radius - min_radius;
+
+       destination = cairo_image_surface_create (format, width, height);
+       destination_stride = cairo_image_surface_get_stride (destination);
+
+       p_source_line = _cairo_image_surface_flush_and_get_data (source);
+       p_blurred_line = _cairo_image_surface_flush_and_get_data (blurred);
+       p_destination_line = _cairo_image_surface_flush_and_get_data (destination);
+       for (y = 0; y < height; y++) {
+               gth_async_task_get_data (task, NULL, &cancelled, NULL);
+               if (cancelled)
+                       break;
+
+               progress = (double) y / height;
+               gth_async_task_set_data (task, NULL, NULL, &progress);
+
+               p_source = p_source_line;
+               p_blurred = p_blurred_line;
+               p_destination = p_destination_line;
+               for (x = 0; x < width; x++) {
+                       d = sqrt (SQR (x - center_x) + SQR (y - center_y));
+                       d = CLAMP_PIXEL (d < min_radius ? 0 : d > max_radius ? 255 : (255.0 * ((d - 
min_radius) / max_distance)));
+
+                       CAIRO_GET_RGBA (p_source, image_red, image_green, image_blue, image_alpha);
+
+                       /* blurred image layer with a radial mask (to blur the edges) */
+
+                       CAIRO_GET_RGBA (p_blurred, layer_red, layer_green, layer_blue, layer_alpha);
+                       layer_alpha = (guchar) (d);
+                       /*layer_red = layer_green = layer_blue = 0;*/
+                       p_destination[CAIRO_RED] = GIMP_OP_NORMAL (layer_red, image_red, layer_alpha);
+                       p_destination[CAIRO_GREEN] = GIMP_OP_NORMAL (layer_green, image_green, layer_alpha);
+                       p_destination[CAIRO_BLUE] = GIMP_OP_NORMAL (layer_blue, image_blue, layer_alpha);
+                       p_destination[CAIRO_ALPHA] = 255;
+
+                       p_source += 4;
+                       p_blurred += 4;
+                       p_destination += 4;
+               }
+               p_source_line += source_stride;
+               p_blurred_line += blurred_stride;
+               p_destination_line += destination_stride;
+       }
+
+       if (! cancelled) {
+               cairo_surface_mark_dirty (destination);
+               gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), destination);
+       }
+
+       cairo_surface_destroy (destination);
+       cairo_surface_destroy (blurred);
+       cairo_surface_destroy (source);
+
+       return NULL;
+}
+
+
+void
+blurred_edges_add_to_special_effects (GthFilterGrid *grid)
+{
+       gth_filter_grid_add_filter (grid,
+                                   GTH_FILTER_GRID_NEW_FILTER_ID,
+                                   gth_image_task_new (_("Applying changes"), NULL, blurred_edges_exec, 
NULL, NULL, NULL),
+                                   _("Blurred Edges"),
+                                   NULL);
+}
+
+
+/* -- Vignette -- */
+
+
+static gpointer
+vignette_exec (GthAsyncTask *task,
+              gpointer      user_data)
+{
+       cairo_surface_t *original;
+       cairo_surface_t *destination;
+       gboolean         cancelled = FALSE;
+
+       original = gth_image_task_get_source_surface (GTH_IMAGE_TASK (task));
+       destination = _cairo_image_surface_copy (original);
+
+       if (cairo_image_surface_apply_vignette (destination, NULL, 127, task))
+                       gth_image_task_set_destination_surface (GTH_IMAGE_TASK (task), destination);
+
+       cairo_surface_destroy (destination);
+       cairo_surface_destroy (original);
+
+       return NULL;
+}
+
+
+void
+vignette_add_to_special_effects (GthFilterGrid *grid)
+{
+       gth_filter_grid_add_filter (grid,
+                                   GTH_FILTER_GRID_NEW_FILTER_ID,
+                                   gth_image_task_new (_("Applying changes"), NULL, vignette_exec, NULL, 
NULL, NULL),
+                                   _("Vignette"),
+                                   NULL);
+}
diff --git a/extensions/file_tools/gth-file-tool-effects.h b/extensions/file_tools/gth-file-tool-effects.h
index 2b60678..3d22212 100644
--- a/extensions/file_tools/gth-file-tool-effects.h
+++ b/extensions/file_tools/gth-file-tool-effects.h
@@ -49,12 +49,17 @@ struct _GthFileToolEffectsClass {
 
 GType  gth_file_tool_effects_get_type  (void);
 
-void warmer_add_to_special_effects     (GthFilterGrid *);
-void cooler_add_to_special_effects     (GthFilterGrid *);
-void instagram_add_to_special_effects  (GthFilterGrid *);
-void cherry_add_to_special_effects     (GthFilterGrid *);
-void grapes_add_to_special_effects     (GthFilterGrid *);
-void vintage_add_to_special_effects    (GthFilterGrid *);
+void warmer_add_to_special_effects             (GthFilterGrid *);
+void cooler_add_to_special_effects             (GthFilterGrid *);
+void soil_add_to_special_effects               (GthFilterGrid *);
+void desert_add_to_special_effects             (GthFilterGrid *);
+void artic_add_to_special_effects              (GthFilterGrid *);
+void mangos_add_to_special_effects             (GthFilterGrid *);
+void fresh_blue_add_to_special_effects         (GthFilterGrid *);
+void cherry_add_to_special_effects             (GthFilterGrid *);
+void vintage_add_to_special_effects            (GthFilterGrid *);
+void blurred_edges_add_to_special_effects      (GthFilterGrid *);
+void vignette_add_to_special_effects           (GthFilterGrid *);
 
 G_END_DECLS
 
diff --git a/extensions/file_tools/gth-file-tool-lomo.c b/extensions/file_tools/gth-file-tool-lomo.c
index c085325..0620164 100644
--- a/extensions/file_tools/gth-file-tool-lomo.c
+++ b/extensions/file_tools/gth-file-tool-lomo.c
@@ -129,7 +129,7 @@ lomo_exec (GthAsyncTask *task,
                        /* blurred image layer with a radial mask (to blur the edges) */
 
                        CAIRO_GET_RGBA (p_blurred, layer_red, layer_green, layer_blue, layer_alpha);
-                       layer_alpha = 255 - d;
+                       layer_alpha = (guchar) (255 - d);
                        image_red = GIMP_OP_NORMAL (layer_red, image_red, layer_alpha);
                        image_green = GIMP_OP_NORMAL (layer_green, image_green, layer_alpha);
                        image_blue = GIMP_OP_NORMAL (layer_blue, image_blue, layer_alpha);
diff --git a/extensions/file_tools/main.c b/extensions/file_tools/main.c
index b3b6614..25f85dc 100644
--- a/extensions/file_tools/main.c
+++ b/extensions/file_tools/main.c
@@ -48,6 +48,8 @@
 G_MODULE_EXPORT void
 gthumb_extension_activate (void)
 {
+       int p;
+
        gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_SAVE);
        gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_SAVE_AS);
        gth_main_register_type ("file-tools", GTH_TYPE_FILE_TOOL_UNDO);
@@ -78,14 +80,20 @@ gthumb_extension_activate (void)
         **/
        gth_hook_register ("add-special-effect", 1);
 
-       gth_hook_add_callback ("add-special-effect", 10, G_CALLBACK (warmer_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 20, G_CALLBACK (cooler_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 30, G_CALLBACK (cherry_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 40, G_CALLBACK (grapes_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 50, G_CALLBACK (instagram_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 60, G_CALLBACK (lomo_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 70, G_CALLBACK (vintage_add_to_special_effects), NULL);
-       gth_hook_add_callback ("add-special-effect", 80, G_CALLBACK (negative_add_to_special_effects), NULL);
+       p = 10;
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (desert_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (cherry_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (soil_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (artic_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (fresh_blue_add_to_special_effects), 
NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (mangos_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (warmer_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (cooler_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (vintage_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (lomo_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (vignette_add_to_special_effects), NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (blurred_edges_add_to_special_effects), 
NULL);
+       gth_hook_add_callback ("add-special-effect", p++, G_CALLBACK (negative_add_to_special_effects), NULL);
 }
 
 


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