[gegl] Bug 749902 - Add Hue-Chroma operation/tool and LCH color selector
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] Bug 749902 - Add Hue-Chroma operation/tool and LCH color selector
- Date: Sun, 7 May 2017 16:27:06 +0000 (UTC)
commit 78c84f94a6633c5d79503d2c1de8125b307c705f
Author: Michael Natterer <mitch gimp org>
Date: Sun May 7 18:26:35 2017 +0200
Bug 749902 - Add Hue-Chroma operation/tool and LCH color selector
Add hue-chroma operation.
operations/common/Makefile.am | 3 +-
operations/common/hue-chroma.c | 114 ++++++++++++++++++++++++++++++++++++++++
po/POTFILES.in | 1 +
3 files changed, 117 insertions(+), 1 deletions(-)
---
diff --git a/operations/common/Makefile.am b/operations/common/Makefile.am
index 74e42ec..5b0a655 100644
--- a/operations/common/Makefile.am
+++ b/operations/common/Makefile.am
@@ -14,7 +14,7 @@ LIBS = $(op_libs)
opdir = $(ext_dir)
op_LTLIBRARIES = \
gegl-common.la
-
+
gegl_common_la_SOURCES =\
alien-map.c \
module.c \
@@ -70,6 +70,7 @@ gegl_common_la_SOURCES =\
grey.c \
grid.c \
high-pass.c \
+ hue-chroma.c \
illusion.c \
image-compare.c \
image-gradient.c \
diff --git a/operations/common/hue-chroma.c b/operations/common/hue-chroma.c
new file mode 100644
index 0000000..b6712ec
--- /dev/null
+++ b/operations/common/hue-chroma.c
@@ -0,0 +1,114 @@
+/* This file is an image processing operation for GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2017 Elle Stone <ellestone ninedegreesbelow com>
+ * Michael Natterer <mitch gimp org>
+ */
+
+#include "config.h"
+#include <glib/gi18n-lib.h>
+
+#ifdef GEGL_PROPERTIES
+
+property_double (hue, _("Hue"), 0.0)
+ description (_("Hue adjustment"))
+ value_range (-180.0, 180.0)
+
+property_double (chroma, _("Chroma"), 0.0)
+ description (_("Chroma adjustment"))
+ value_range (-100.0, 100.0)
+
+property_double (lightness, _("Lightness"), 0.0)
+ description (_("Lightness adjustment"))
+ value_range (-100.0, 100.0)
+
+#else
+
+#define GEGL_OP_POINT_FILTER
+
+#define GEGL_OP_NAME hue_chroma
+#define GEGL_OP_C_SOURCE hue-chroma.c
+
+#include "gegl-op.h"
+
+static void
+prepare (GeglOperation *operation)
+{
+ gegl_operation_set_format (operation, "input",
+ babl_format ("CIE LCH(ab) alpha float"));
+ gegl_operation_set_format (operation, "output",
+ babl_format ("CIE LCH(ab) alpha float"));
+}
+
+static gboolean
+process (GeglOperation *op,
+ void *in_buf,
+ void *out_buf,
+ glong n_pixels,
+ const GeglRectangle *roi,
+ gint level)
+{
+ GeglProperties *o = GEGL_PROPERTIES (op);
+ gfloat *GEGL_ALIGNED in_pixel;
+ gfloat *GEGL_ALIGNED out_pixel;
+ gfloat hue;
+ gfloat chroma;
+ gfloat lightness;
+
+ in_pixel = in_buf;
+ out_pixel = out_buf;
+
+ hue = o->hue;
+ chroma = o->chroma;
+ lightness = o->lightness;
+
+ while (n_pixels--)
+ {
+ out_pixel[0] = in_pixel[0] + lightness;
+ out_pixel[1] = in_pixel[1] + chroma;
+ out_pixel[2] = in_pixel[2] + hue;
+
+ out_pixel[1] = CLAMP (out_pixel[1], 0, 200.0);
+
+ out_pixel[3] = in_pixel[3];
+
+ in_pixel += 4;
+ out_pixel += 4;
+ }
+
+ return TRUE;
+}
+
+static void
+gegl_op_class_init (GeglOpClass *klass)
+{
+ GeglOperationClass *operation_class;
+ GeglOperationPointFilterClass *point_filter_class;
+
+ operation_class = GEGL_OPERATION_CLASS (klass);
+ point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ operation_class->prepare = prepare;
+ point_filter_class->process = process;
+
+ gegl_operation_class_set_keys (operation_class,
+ "name", "gegl:hue-chroma",
+ "title", _("Hue-Chroma"),
+ "categories", "color",
+ "description", _("Adjust LCH Hue, Chroma, and Lightness"),
+ NULL);
+}
+
+#endif
diff --git a/po/POTFILES.in b/po/POTFILES.in
index e95a8f7..c05c747 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -59,6 +59,7 @@ operations/common/gegl.c
operations/common/grey.c
operations/common/grid.c
operations/common/high-pass.c
+operations/common/hue-chroma.c
operations/common/illusion.c
operations/common/image-compare.c
operations/common/image-gradient.c
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]