[gimp] Bug 756822 - Colors/Desaturate/Luminosity should operate on linear RGB



commit 68a9835d5646341ebd21b1632e97e1a78f851252
Author: Michael Natterer <mitch gimp org>
Date:   Thu Oct 22 19:50:56 2015 +0200

    Bug 756822 - Colors/Desaturate/Luminosity should operate on linear RGB
    
    Add GIMP_DESATURATE_LUMINANCE to enum GimpDesaturateMode and rename
    GIMP_DESATURATE_LUMINOSITY to GIMP_DESATURATE_LUMA.
    
    Keep GIMP_DESATURATE_LUMINOSITY as deprecated compat value and add it
    to the script-fo and pygimp compat constants.
    
    Change GimpOperationDesaturate to process GIMP_DESATURATE_LUMINANCE
    with linear "RGBA float".

 app/operations/gimpoperationdesaturate.c |   28 ++++++++++++++++++++++++++--
 libgimpbase/gimpbaseenums.c              |    6 ++++--
 libgimpbase/gimpbaseenums.h              |    9 +++++++--
 plug-ins/pygimp/gimpenumsmodule.c        |    3 +++
 plug-ins/script-fu/scheme-wrapper.c      |    2 ++
 tools/pdbgen/enums.pl                    |    9 +++++----
 6 files changed, 47 insertions(+), 10 deletions(-)
---
diff --git a/app/operations/gimpoperationdesaturate.c b/app/operations/gimpoperationdesaturate.c
index fac1760..5e8b87a 100644
--- a/app/operations/gimpoperationdesaturate.c
+++ b/app/operations/gimpoperationdesaturate.c
@@ -32,6 +32,7 @@
 #include "gimpdesaturateconfig.h"
 
 
+static void      gimp_operation_desaturate_prepare (GeglOperation       *operation);
 static gboolean  gimp_operation_desaturate_process (GeglOperation       *operation,
                                                     void                *in_buf,
                                                     void                *out_buf,
@@ -62,7 +63,9 @@ gimp_operation_desaturate_class_init (GimpOperationDesaturateClass *klass)
                                  "description", "GIMP Desaturate operation",
                                  NULL);
 
-  point_class->process = gimp_operation_desaturate_process;
+  operation_class->prepare = gimp_operation_desaturate_prepare;
+
+  point_class->process     = gimp_operation_desaturate_process;
 
   g_object_class_install_property (object_class,
                                    GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
@@ -79,6 +82,26 @@ gimp_operation_desaturate_init (GimpOperationDesaturate *self)
 {
 }
 
+static void
+gimp_operation_desaturate_prepare (GeglOperation *operation)
+{
+  GimpOperationPointFilter *point  = GIMP_OPERATION_POINT_FILTER (operation);
+  GimpDesaturateConfig     *config = GIMP_DESATURATE_CONFIG (point->config);
+  const Babl               *format;
+
+  if (config->mode == GIMP_DESATURATE_LUMINANCE)
+    {
+      format = babl_format ("RGBA float");
+    }
+  else
+    {
+      format = babl_format ("R'G'B'A float");
+    }
+
+  gegl_operation_set_format (operation, "input",  format);
+  gegl_operation_set_format (operation, "output", format);
+}
+
 static gboolean
 gimp_operation_desaturate_process (GeglOperation       *operation,
                                    void                *in_buf,
@@ -119,7 +142,8 @@ gimp_operation_desaturate_process (GeglOperation       *operation,
         }
       break;
 
-    case GIMP_DESATURATE_LUMINOSITY:
+    case GIMP_DESATURATE_LUMA:
+    case GIMP_DESATURATE_LUMINANCE:
       while (samples--)
         {
           gfloat value = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]);
diff --git a/libgimpbase/gimpbaseenums.c b/libgimpbase/gimpbaseenums.c
index 5413524..94748e8 100644
--- a/libgimpbase/gimpbaseenums.c
+++ b/libgimpbase/gimpbaseenums.c
@@ -426,16 +426,18 @@ gimp_desaturate_mode_get_type (void)
   static const GEnumValue values[] =
   {
     { GIMP_DESATURATE_LIGHTNESS, "GIMP_DESATURATE_LIGHTNESS", "lightness" },
-    { GIMP_DESATURATE_LUMINOSITY, "GIMP_DESATURATE_LUMINOSITY", "luminosity" },
+    { GIMP_DESATURATE_LUMA, "GIMP_DESATURATE_LUMA", "luma" },
     { GIMP_DESATURATE_AVERAGE, "GIMP_DESATURATE_AVERAGE", "average" },
+    { GIMP_DESATURATE_LUMINANCE, "GIMP_DESATURATE_LUMINANCE", "luminance" },
     { 0, NULL, NULL }
   };
 
   static const GimpEnumDesc descs[] =
   {
     { GIMP_DESATURATE_LIGHTNESS, NC_("desaturate-mode", "Lightness"), NULL },
-    { GIMP_DESATURATE_LUMINOSITY, NC_("desaturate-mode", "Luminosity"), NULL },
+    { GIMP_DESATURATE_LUMA, NC_("desaturate-mode", "Luma"), NULL },
     { GIMP_DESATURATE_AVERAGE, NC_("desaturate-mode", "Average"), NULL },
+    { GIMP_DESATURATE_LUMINANCE, NC_("desaturate-mode", "Luminance"), NULL },
     { 0, NULL, NULL }
   };
 
diff --git a/libgimpbase/gimpbaseenums.h b/libgimpbase/gimpbaseenums.h
index a7c304b..06fb7d2 100644
--- a/libgimpbase/gimpbaseenums.h
+++ b/libgimpbase/gimpbaseenums.h
@@ -233,8 +233,13 @@ GType gimp_desaturate_mode_get_type (void) G_GNUC_CONST;
 typedef enum
 {
   GIMP_DESATURATE_LIGHTNESS,   /*< desc="Lightness"  >*/
-  GIMP_DESATURATE_LUMINOSITY,  /*< desc="Luminosity" >*/
-  GIMP_DESATURATE_AVERAGE      /*< desc="Average"    >*/
+  GIMP_DESATURATE_LUMA,        /*< desc="Luma"       >*/
+  GIMP_DESATURATE_AVERAGE,     /*< desc="Average"    >*/
+  GIMP_DESATURATE_LUMINANCE,   /*< desc="Luminance"  >*/
+
+#ifndef GIMP_DISABLE_DEPRECATED
+  GIMP_DESATURATE_LUMINOSITY = GIMP_DESATURATE_LUMA /*< skip, pdb-skip >*/
+#endif /* GIMP_DISABLE_DEPRECATED */
 } GimpDesaturateMode;
 
 
diff --git a/plug-ins/pygimp/gimpenumsmodule.c b/plug-ins/pygimp/gimpenumsmodule.c
index fbc6914..d2cf1d4 100644
--- a/plug-ins/pygimp/gimpenumsmodule.c
+++ b/plug-ins/pygimp/gimpenumsmodule.c
@@ -153,6 +153,9 @@ add_compat_enums(PyObject *m)
     PyModule_AddIntConstant(m, "HIGHLIGHTS",
                             GIMP_TRANSFER_HIGHLIGHTS);
 
+    PyModule_AddIntConstant(m, "DESATURATE_LUMINOSITY",
+                            GIMP_DESATURATE_LUMA);
+
     PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_RGB",
                             GIMP_EXPORT_CAN_HANDLE_RGB);
     PyModule_AddIntConstant(m, "EXPORT_CAN_HANDLE_GRAY",
diff --git a/plug-ins/script-fu/scheme-wrapper.c b/plug-ins/script-fu/scheme-wrapper.c
index 6cfd1d9..b421bff 100644
--- a/plug-ins/script-fu/scheme-wrapper.c
+++ b/plug-ins/script-fu/scheme-wrapper.c
@@ -169,6 +169,8 @@ static const NamedConstant const old_constants[] =
   { "MIDTONES",                GIMP_TRANSFER_MIDTONES   },
   { "HIGHLIGHTS",              GIMP_TRANSFER_HIGHLIGHTS },
 
+  { "DESATURATE-LUMINOSITY",   GIMP_DESATURATE_LUMA },
+
   { NULL, 0 }
 };
 
diff --git a/tools/pdbgen/enums.pl b/tools/pdbgen/enums.pl
index 65ec99d..43c473b 100644
--- a/tools/pdbgen/enums.pl
+++ b/tools/pdbgen/enums.pl
@@ -129,11 +129,12 @@ package Gimp::CodeGen::enums;
     GimpDesaturateMode =>
        { contig => 1,
          header => 'libgimpbase/gimpbaseenums.h',
-         symbols => [ qw(GIMP_DESATURATE_LIGHTNESS
-                         GIMP_DESATURATE_LUMINOSITY GIMP_DESATURATE_AVERAGE) ],
+         symbols => [ qw(GIMP_DESATURATE_LIGHTNESS GIMP_DESATURATE_LUMA
+                         GIMP_DESATURATE_AVERAGE GIMP_DESATURATE_LUMINANCE) ],
          mapping => { GIMP_DESATURATE_LIGHTNESS => '0',
-                      GIMP_DESATURATE_LUMINOSITY => '1',
-                      GIMP_DESATURATE_AVERAGE => '2' }
+                      GIMP_DESATURATE_LUMA => '1',
+                      GIMP_DESATURATE_AVERAGE => '2',
+                      GIMP_DESATURATE_LUMINANCE => '3' }
        },
     GimpDodgeBurnType =>
        { contig => 1,


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