[gimp/metadata-browser] app: create an own GimpOperationBrightnessContrast
- From: Roman Joost <romanofski src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/metadata-browser] app: create an own GimpOperationBrightnessContrast
- Date: Wed, 12 Sep 2012 22:58:11 +0000 (UTC)
commit 668ad7439936aa4b839980dc0b1044e400bcf769
Author: Michael Natterer <mitch gimp org>
Date: Tue Mar 13 15:02:17 2012 +0100
app: create an own GimpOperationBrightnessContrast
and use it instead of gegl:brightness-contrast because the GEGL op is
giving different reaults.
app/core/gimpdrawable-brightness-contrast.c | 10 +-
app/gegl/Makefile.am | 212 ++++++++++++++-------------
app/gegl/gimp-gegl-types.h | 104 +++++++-------
app/gegl/gimp-gegl.c | 2 +
app/gegl/gimpbrightnesscontrastconfig.c | 21 ---
app/gegl/gimpbrightnesscontrastconfig.h | 3 -
app/gegl/gimpoperationbrightnesscontrast.c | 134 +++++++++++++++++
app/gegl/gimpoperationbrightnesscontrast.h | 52 +++++++
app/tools/gimpbrightnesscontrasttool.c | 16 ++-
9 files changed, 364 insertions(+), 190 deletions(-)
---
diff --git a/app/core/gimpdrawable-brightness-contrast.c b/app/core/gimpdrawable-brightness-contrast.c
index 20f54f4..00205c95 100644
--- a/app/core/gimpdrawable-brightness-contrast.c
+++ b/app/core/gimpdrawable-brightness-contrast.c
@@ -62,12 +62,13 @@ gimp_drawable_brightness_contrast (GimpDrawable *drawable,
GeglNode *node;
node = g_object_new (GEGL_TYPE_NODE,
- "operation", "gegl:brightness-contrast",
+ "operation", "gimp:brightness-contrast",
+ "config", config,
NULL);
- gimp_brightness_contrast_config_set_node (config, node);
gimp_drawable_apply_operation (drawable, progress,
- C_("undo-type", "Brightness_Contrast"), node, TRUE);
+ C_("undo-type", "Brightness-Contrast")
+ , node, TRUE);
g_object_unref (node);
}
else
@@ -78,7 +79,8 @@ gimp_drawable_brightness_contrast (GimpDrawable *drawable,
config->contrast,
gimp_drawable_bytes (drawable));
- gimp_drawable_process_lut (drawable, progress, C_("undo-type", "Brightness-Contrast"),
+ gimp_drawable_process_lut (drawable, progress,
+ C_("undo-type", "Brightness-Contrast"),
lut);
gimp_lut_free (lut);
}
diff --git a/app/gegl/Makefile.am b/app/gegl/Makefile.am
index addc33f..c6da5c3 100644
--- a/app/gegl/Makefile.am
+++ b/app/gegl/Makefile.am
@@ -16,115 +16,117 @@ INCLUDES = \
noinst_LIBRARIES = libappgegl.a
libappgegl_a_sources = \
- gimp-gegl-enums.h \
- gimp-gegl-types.h \
- gimp-gegl.c \
- gimp-gegl.h \
- gimp-gegl-utils.c \
- gimp-gegl-utils.h \
- gimptilebackendtilemanager.c \
- gimptilebackendtilemanager.h \
+ gimp-gegl-enums.h \
+ gimp-gegl-types.h \
+ gimp-gegl.c \
+ gimp-gegl.h \
+ gimp-gegl-utils.c \
+ gimp-gegl-utils.h \
+ gimptilebackendtilemanager.c \
+ gimptilebackendtilemanager.h \
\
- gimpbrightnesscontrastconfig.c \
- gimpbrightnesscontrastconfig.h \
- gimpcageconfig.c \
- gimpcageconfig.h \
- gimpcolorbalanceconfig.c \
- gimpcolorbalanceconfig.h \
- gimpcolorizeconfig.c \
- gimpcolorizeconfig.h \
- gimpcurvesconfig.c \
- gimpcurvesconfig.h \
- gimpdesaturateconfig.c \
- gimpdesaturateconfig.h \
- gimphuesaturationconfig.c \
- gimphuesaturationconfig.h \
- gimplevelsconfig.c \
- gimplevelsconfig.h \
- gimpposterizeconfig.c \
- gimpposterizeconfig.h \
- gimpthresholdconfig.c \
- gimpthresholdconfig.h \
+ gimpbrightnesscontrastconfig.c \
+ gimpbrightnesscontrastconfig.h \
+ gimpcageconfig.c \
+ gimpcageconfig.h \
+ gimpcolorbalanceconfig.c \
+ gimpcolorbalanceconfig.h \
+ gimpcolorizeconfig.c \
+ gimpcolorizeconfig.h \
+ gimpcurvesconfig.c \
+ gimpcurvesconfig.h \
+ gimpdesaturateconfig.c \
+ gimpdesaturateconfig.h \
+ gimphuesaturationconfig.c \
+ gimphuesaturationconfig.h \
+ gimplevelsconfig.c \
+ gimplevelsconfig.h \
+ gimpposterizeconfig.c \
+ gimpposterizeconfig.h \
+ gimpthresholdconfig.c \
+ gimpthresholdconfig.h \
\
- gimpoperationtilesink.c \
- gimpoperationtilesink.h \
- gimpoperationtilesource.c \
- gimpoperationtilesource.h \
+ gimpoperationtilesink.c \
+ gimpoperationtilesink.h \
+ gimpoperationtilesource.c \
+ gimpoperationtilesource.h \
\
- gimpoperationpointfilter.c \
- gimpoperationpointfilter.h \
- gimpoperationcolorbalance.c \
- gimpoperationcolorbalance.h \
- gimpoperationcolorize.c \
- gimpoperationcolorize.h \
- gimpoperationcagecoefcalc.c \
- gimpoperationcagecoefcalc.h \
- gimpoperationcagetransform.c \
- gimpoperationcagetransform.h \
- gimpoperationcurves.c \
- gimpoperationcurves.h \
- gimpoperationdesaturate.c \
- gimpoperationdesaturate.h \
- gimpoperationhuesaturation.c \
- gimpoperationhuesaturation.h \
- gimpoperationlevels.c \
- gimpoperationlevels.h \
- gimpoperationposterize.c \
- gimpoperationposterize.h \
- gimpoperationthreshold.c \
- gimpoperationthreshold.h \
+ gimpoperationpointfilter.c \
+ gimpoperationpointfilter.h \
+ gimpoperationbrightnesscontrast.c \
+ gimpoperationbrightnesscontrast.h \
+ gimpoperationcolorbalance.c \
+ gimpoperationcolorbalance.h \
+ gimpoperationcolorize.c \
+ gimpoperationcolorize.h \
+ gimpoperationcagecoefcalc.c \
+ gimpoperationcagecoefcalc.h \
+ gimpoperationcagetransform.c \
+ gimpoperationcagetransform.h \
+ gimpoperationcurves.c \
+ gimpoperationcurves.h \
+ gimpoperationdesaturate.c \
+ gimpoperationdesaturate.h \
+ gimpoperationhuesaturation.c \
+ gimpoperationhuesaturation.h \
+ gimpoperationlevels.c \
+ gimpoperationlevels.h \
+ gimpoperationposterize.c \
+ gimpoperationposterize.h \
+ gimpoperationthreshold.c \
+ gimpoperationthreshold.h \
\
- gimpoperationpointlayermode.c \
- gimpoperationpointlayermode.h \
- gimpoperationdissolvemode.c \
- gimpoperationdissolvemode.h \
- gimpoperationbehindmode.c \
- gimpoperationbehindmode.h \
- gimpoperationmultiplymode.c \
- gimpoperationmultiplymode.h \
- gimpoperationscreenmode.c \
- gimpoperationscreenmode.h \
- gimpoperationoverlaymode.c \
- gimpoperationoverlaymode.h \
- gimpoperationdifferencemode.c \
- gimpoperationdifferencemode.h \
- gimpoperationadditionmode.c \
- gimpoperationadditionmode.h \
- gimpoperationsubtractmode.c \
- gimpoperationsubtractmode.h \
- gimpoperationdarkenonlymode.c \
- gimpoperationdarkenonlymode.h \
- gimpoperationlightenonlymode.c \
- gimpoperationlightenonlymode.h \
- gimpoperationhuemode.c \
- gimpoperationhuemode.h \
- gimpoperationsaturationmode.c \
- gimpoperationsaturationmode.h \
- gimpoperationcolormode.c \
- gimpoperationcolormode.h \
- gimpoperationvaluemode.c \
- gimpoperationvaluemode.h \
- gimpoperationdividemode.c \
- gimpoperationdividemode.h \
- gimpoperationdodgemode.c \
- gimpoperationdodgemode.h \
- gimpoperationburnmode.c \
- gimpoperationburnmode.h \
- gimpoperationhardlightmode.c \
- gimpoperationhardlightmode.h \
- gimpoperationsoftlightmode.c \
- gimpoperationsoftlightmode.h \
- gimpoperationgrainextractmode.c \
- gimpoperationgrainextractmode.h \
- gimpoperationgrainmergemode.c \
- gimpoperationgrainmergemode.h \
- gimpoperationcolorerasemode.c \
- gimpoperationcolorerasemode.h \
- gimpoperationerasemode.c \
- gimpoperationerasemode.h \
- gimpoperationreplacemode.c \
- gimpoperationreplacemode.h \
- gimpoperationantierasemode.c \
+ gimpoperationpointlayermode.c \
+ gimpoperationpointlayermode.h \
+ gimpoperationdissolvemode.c \
+ gimpoperationdissolvemode.h \
+ gimpoperationbehindmode.c \
+ gimpoperationbehindmode.h \
+ gimpoperationmultiplymode.c \
+ gimpoperationmultiplymode.h \
+ gimpoperationscreenmode.c \
+ gimpoperationscreenmode.h \
+ gimpoperationoverlaymode.c \
+ gimpoperationoverlaymode.h \
+ gimpoperationdifferencemode.c \
+ gimpoperationdifferencemode.h \
+ gimpoperationadditionmode.c \
+ gimpoperationadditionmode.h \
+ gimpoperationsubtractmode.c \
+ gimpoperationsubtractmode.h \
+ gimpoperationdarkenonlymode.c \
+ gimpoperationdarkenonlymode.h \
+ gimpoperationlightenonlymode.c \
+ gimpoperationlightenonlymode.h \
+ gimpoperationhuemode.c \
+ gimpoperationhuemode.h \
+ gimpoperationsaturationmode.c \
+ gimpoperationsaturationmode.h \
+ gimpoperationcolormode.c \
+ gimpoperationcolormode.h \
+ gimpoperationvaluemode.c \
+ gimpoperationvaluemode.h \
+ gimpoperationdividemode.c \
+ gimpoperationdividemode.h \
+ gimpoperationdodgemode.c \
+ gimpoperationdodgemode.h \
+ gimpoperationburnmode.c \
+ gimpoperationburnmode.h \
+ gimpoperationhardlightmode.c \
+ gimpoperationhardlightmode.h \
+ gimpoperationsoftlightmode.c \
+ gimpoperationsoftlightmode.h \
+ gimpoperationgrainextractmode.c \
+ gimpoperationgrainextractmode.h \
+ gimpoperationgrainmergemode.c \
+ gimpoperationgrainmergemode.h \
+ gimpoperationcolorerasemode.c \
+ gimpoperationcolorerasemode.h \
+ gimpoperationerasemode.c \
+ gimpoperationerasemode.h \
+ gimpoperationreplacemode.c \
+ gimpoperationreplacemode.h \
+ gimpoperationantierasemode.c \
gimpoperationantierasemode.h
libappgegl_a_built_sources = gimp-gegl-enums.c
diff --git a/app/gegl/gimp-gegl-types.h b/app/gegl/gimp-gegl-types.h
index 4f066f5..130fd09 100644
--- a/app/gegl/gimp-gegl-types.h
+++ b/app/gegl/gimp-gegl-types.h
@@ -27,61 +27,63 @@
/* operations */
-typedef struct _GimpOperationTileSink GimpOperationTileSink;
-typedef struct _GimpOperationTileSource GimpOperationTileSource;
-
-typedef struct _GimpOperationPointFilter GimpOperationPointFilter;
-typedef struct _GimpOperationColorBalance GimpOperationColorBalance;
-typedef struct _GimpOperationColorize GimpOperationColorize;
-typedef struct _GimpOperationCageCoefCalc GimpOperationCageCoefCalc;
-typedef struct _GimpOperationCageTransform GimpOperationCageTransform;
-typedef struct _GimpOperationCurves GimpOperationCurves;
-typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
-typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation;
-typedef struct _GimpOperationLevels GimpOperationLevels;
-typedef struct _GimpOperationPosterize GimpOperationPosterize;
-typedef struct _GimpOperationThreshold GimpOperationThreshold;
-
-typedef struct _GimpOperationPointLayerMode GimpOperationPointLayerMode;
-typedef struct _GimpOperationDissolveMode GimpOperationDissolveMode;
-typedef struct _GimpOperationBehindMode GimpOperationBehindMode;
-typedef struct _GimpOperationMultiplyMode GimpOperationMultiplyMode;
-typedef struct _GimpOperationScreenMode GimpOperationScreenMode;
-typedef struct _GimpOperationOverlayMode GimpOperationOverlayMode;
-typedef struct _GimpOperationDifferenceMode GimpOperationDifferenceMode;
-typedef struct _GimpOperationAdditionMode GimpOperationAdditionMode;
-typedef struct _GimpOperationSubtractMode GimpOperationSubtractMode;
-typedef struct _GimpOperationDarkenOnlyMode GimpOperationDarkenOnlyMode;
-typedef struct _GimpOperationLightenOnlyMode GimpOperationLightenOnlyMode;
-typedef struct _GimpOperationHueMode GimpOperationHueMode;
-typedef struct _GimpOperationSaturationMode GimpOperationSaturationMode;
-typedef struct _GimpOperationColorMode GimpOperationColorMode;
-typedef struct _GimpOperationValueMode GimpOperationValueMode;
-typedef struct _GimpOperationDivideMode GimpOperationDivideMode;
-typedef struct _GimpOperationDodgeMode GimpOperationDodgeMode;
-typedef struct _GimpOperationBurnMode GimpOperationBurnMode;
-typedef struct _GimpOperationHardlightMode GimpOperationHardlightMode;
-typedef struct _GimpOperationSoftlightMode GimpOperationSoftlightMode;
-typedef struct _GimpOperationGrainExtractMode GimpOperationGrainExtractMode;
-typedef struct _GimpOperationGrainMergeMode GimpOperationGrainMergeMode;
-typedef struct _GimpOperationColorEraseMode GimpOperationColorEraseMode;
-typedef struct _GimpOperationEraseMode GimpOperationEraseMode;
-typedef struct _GimpOperationReplaceMode GimpOperationReplaceMode;
-typedef struct _GimpOperationAntiEraseMode GimpOperationAntiEraseMode;
+typedef struct _GimpOperationTileSink GimpOperationTileSink;
+typedef struct _GimpOperationTileSource GimpOperationTileSource;
+
+typedef struct _GimpOperationCageCoefCalc GimpOperationCageCoefCalc;
+typedef struct _GimpOperationCageTransform GimpOperationCageTransform;
+
+typedef struct _GimpOperationPointFilter GimpOperationPointFilter;
+typedef struct _GimpOperationBrightnessContrast GimpOperationBrightnessContrast;
+typedef struct _GimpOperationColorBalance GimpOperationColorBalance;
+typedef struct _GimpOperationColorize GimpOperationColorize;
+typedef struct _GimpOperationCurves GimpOperationCurves;
+typedef struct _GimpOperationDesaturate GimpOperationDesaturate;
+typedef struct _GimpOperationHueSaturation GimpOperationHueSaturation;
+typedef struct _GimpOperationLevels GimpOperationLevels;
+typedef struct _GimpOperationPosterize GimpOperationPosterize;
+typedef struct _GimpOperationThreshold GimpOperationThreshold;
+
+typedef struct _GimpOperationPointLayerMode GimpOperationPointLayerMode;
+typedef struct _GimpOperationDissolveMode GimpOperationDissolveMode;
+typedef struct _GimpOperationBehindMode GimpOperationBehindMode;
+typedef struct _GimpOperationMultiplyMode GimpOperationMultiplyMode;
+typedef struct _GimpOperationScreenMode GimpOperationScreenMode;
+typedef struct _GimpOperationOverlayMode GimpOperationOverlayMode;
+typedef struct _GimpOperationDifferenceMode GimpOperationDifferenceMode;
+typedef struct _GimpOperationAdditionMode GimpOperationAdditionMode;
+typedef struct _GimpOperationSubtractMode GimpOperationSubtractMode;
+typedef struct _GimpOperationDarkenOnlyMode GimpOperationDarkenOnlyMode;
+typedef struct _GimpOperationLightenOnlyMode GimpOperationLightenOnlyMode;
+typedef struct _GimpOperationHueMode GimpOperationHueMode;
+typedef struct _GimpOperationSaturationMode GimpOperationSaturationMode;
+typedef struct _GimpOperationColorMode GimpOperationColorMode;
+typedef struct _GimpOperationValueMode GimpOperationValueMode;
+typedef struct _GimpOperationDivideMode GimpOperationDivideMode;
+typedef struct _GimpOperationDodgeMode GimpOperationDodgeMode;
+typedef struct _GimpOperationBurnMode GimpOperationBurnMode;
+typedef struct _GimpOperationHardlightMode GimpOperationHardlightMode;
+typedef struct _GimpOperationSoftlightMode GimpOperationSoftlightMode;
+typedef struct _GimpOperationGrainExtractMode GimpOperationGrainExtractMode;
+typedef struct _GimpOperationGrainMergeMode GimpOperationGrainMergeMode;
+typedef struct _GimpOperationColorEraseMode GimpOperationColorEraseMode;
+typedef struct _GimpOperationEraseMode GimpOperationEraseMode;
+typedef struct _GimpOperationReplaceMode GimpOperationReplaceMode;
+typedef struct _GimpOperationAntiEraseMode GimpOperationAntiEraseMode;
/* operation config objects */
-typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig;
-typedef struct _GimpCageConfig GimpCageConfig;
-typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
-typedef struct _GimpColorizeConfig GimpColorizeConfig;
-typedef struct _GimpCurvesConfig GimpCurvesConfig;
-typedef struct _GimpDesaturateConfig GimpDesaturateConfig;
-typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
-typedef struct _GimpLevelsConfig GimpLevelsConfig;
-typedef struct _GimpPosterizeConfig GimpPosterizeConfig;
-typedef struct _GimpThresholdConfig GimpThresholdConfig;
+typedef struct _GimpBrightnessContrastConfig GimpBrightnessContrastConfig;
+typedef struct _GimpCageConfig GimpCageConfig;
+typedef struct _GimpColorBalanceConfig GimpColorBalanceConfig;
+typedef struct _GimpColorizeConfig GimpColorizeConfig;
+typedef struct _GimpCurvesConfig GimpCurvesConfig;
+typedef struct _GimpDesaturateConfig GimpDesaturateConfig;
+typedef struct _GimpHueSaturationConfig GimpHueSaturationConfig;
+typedef struct _GimpLevelsConfig GimpLevelsConfig;
+typedef struct _GimpPosterizeConfig GimpPosterizeConfig;
+typedef struct _GimpThresholdConfig GimpThresholdConfig;
/* temporary stuff */
diff --git a/app/gegl/gimp-gegl.c b/app/gegl/gimp-gegl.c
index b9f500b..bf03314 100644
--- a/app/gegl/gimp-gegl.c
+++ b/app/gegl/gimp-gegl.c
@@ -31,6 +31,7 @@
#include "core/gimp.h"
#include "gimp-gegl.h"
+#include "gimpoperationbrightnesscontrast.h"
#include "gimpoperationcagecoefcalc.h"
#include "gimpoperationcagetransform.h"
#include "gimpoperationcolorbalance.h"
@@ -97,6 +98,7 @@ gimp_gegl_init (Gimp *gimp)
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SINK);
g_type_class_ref (GIMP_TYPE_OPERATION_TILE_SOURCE);
+ g_type_class_ref (GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST);
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_COEF_CALC);
g_type_class_ref (GIMP_TYPE_OPERATION_CAGE_TRANSFORM);
g_type_class_ref (GIMP_TYPE_OPERATION_COLOR_BALANCE);
diff --git a/app/gegl/gimpbrightnesscontrastconfig.c b/app/gegl/gimpbrightnesscontrastconfig.c
index 3fe7d21..7354420 100644
--- a/app/gegl/gimpbrightnesscontrastconfig.c
+++ b/app/gegl/gimpbrightnesscontrastconfig.c
@@ -135,27 +135,6 @@ gimp_brightness_contrast_config_set_property (GObject *object,
/* public functions */
-void
-gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config,
- GeglNode *node)
-{
- gdouble brightness;
- gdouble contrast;
-
- g_return_if_fail (GIMP_IS_BRIGHTNESS_CONTRAST_CONFIG (config));
- g_return_if_fail (GEGL_IS_NODE (node));
-
- brightness = config->brightness / 2.0;
- contrast = (config->contrast < 0 ?
- (config->contrast + 1.0) :
- config->contrast * 4.0 + 1.0);
-
- gegl_node_set (node,
- "brightness", brightness,
- "contrast", contrast,
- NULL);
-}
-
GimpLevelsConfig *
gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *config)
{
diff --git a/app/gegl/gimpbrightnesscontrastconfig.h b/app/gegl/gimpbrightnesscontrastconfig.h
index aad33be..149c033 100644
--- a/app/gegl/gimpbrightnesscontrastconfig.h
+++ b/app/gegl/gimpbrightnesscontrastconfig.h
@@ -51,9 +51,6 @@ struct _GimpBrightnessContrastConfigClass
GType gimp_brightness_contrast_config_get_type (void) G_GNUC_CONST;
-void gimp_brightness_contrast_config_set_node (GimpBrightnessContrastConfig *config,
- GeglNode *node);
-
GimpLevelsConfig *
gimp_brightness_contrast_config_to_levels_config (GimpBrightnessContrastConfig *config);
diff --git a/app/gegl/gimpoperationbrightnesscontrast.c b/app/gegl/gimpoperationbrightnesscontrast.c
new file mode 100644
index 0000000..2242e3c
--- /dev/null
+++ b/app/gegl/gimpoperationbrightnesscontrast.c
@@ -0,0 +1,134 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationcolorbalance.c
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "config.h"
+
+#include <cairo.h>
+#include <gegl.h>
+
+#include "libgimpcolor/gimpcolor.h"
+#include "libgimpmath/gimpmath.h"
+
+#include "gimp-gegl-types.h"
+
+#include "gimpbrightnesscontrastconfig.h"
+#include "gimpoperationbrightnesscontrast.h"
+
+
+static gboolean gimp_operation_brightness_contrast_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong samples,
+ const GeglRectangle *roi);
+
+
+G_DEFINE_TYPE (GimpOperationBrightnessContrast, gimp_operation_brightness_contrast,
+ GIMP_TYPE_OPERATION_POINT_FILTER)
+
+#define parent_class gimp_operation_brightness_contrast_parent_class
+
+
+static void
+gimp_operation_brightness_contrast_class_init (GimpOperationBrightnessContrastClass *klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationPointFilterClass *point_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
+
+ object_class->set_property = gimp_operation_point_filter_set_property;
+ object_class->get_property = gimp_operation_point_filter_get_property;
+
+ operation_class->name = "gimp:brightness-contrast";
+ operation_class->categories = "color";
+ operation_class->description = "GIMP Brightness-Contrast operation";
+
+ point_class->process = gimp_operation_brightness_contrast_process;
+
+ g_object_class_install_property (object_class,
+ GIMP_OPERATION_POINT_FILTER_PROP_CONFIG,
+ g_param_spec_object ("config",
+ "Config",
+ "The config object",
+ GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG,
+ G_PARAM_READWRITE |
+ G_PARAM_CONSTRUCT));
+}
+
+static void
+gimp_operation_brightness_contrast_init (GimpOperationBrightnessContrast *self)
+{
+}
+
+static inline gfloat
+gimp_operation_brightness_contrast_map (gfloat value,
+ gdouble brightness,
+ gdouble contrast)
+{
+ gdouble slant;
+
+ /* apply brightness */
+ if (brightness < 0.0)
+ value = value * (1.0 + brightness);
+ else
+ value = value + ((1.0 - value) * brightness);
+
+ slant = tan ((contrast + 1) * G_PI_4);
+ value = (value - 0.5) * slant + 0.5;
+
+ return value;
+}
+
+static gboolean
+gimp_operation_brightness_contrast_process (GeglOperation *operation,
+ void *in_buf,
+ void *out_buf,
+ glong samples,
+ const GeglRectangle *roi)
+{
+ GimpOperationPointFilter *point = GIMP_OPERATION_POINT_FILTER (operation);
+ GimpBrightnessContrastConfig *config = GIMP_BRIGHTNESS_CONTRAST_CONFIG (point->config);
+ gfloat *src = in_buf;
+ gfloat *dest = out_buf;
+ gdouble brightness;
+
+ if (! config)
+ return FALSE;
+
+ brightness = config->brightness / 2.0;
+
+ while (samples--)
+ {
+ dest[RED] = gimp_operation_brightness_contrast_map (src[RED],
+ brightness,
+ config->contrast);
+ dest[GREEN] = gimp_operation_brightness_contrast_map (src[GREEN],
+ brightness,
+ config->contrast);
+ dest[BLUE] = gimp_operation_brightness_contrast_map (src[BLUE],
+ brightness,
+ config->contrast);
+ dest[ALPHA] = src[ALPHA];
+
+ src += 4;
+ dest += 4;
+ }
+
+ return TRUE;
+}
diff --git a/app/gegl/gimpoperationbrightnesscontrast.h b/app/gegl/gimpoperationbrightnesscontrast.h
new file mode 100644
index 0000000..5adcf76
--- /dev/null
+++ b/app/gegl/gimpoperationbrightnesscontrast.h
@@ -0,0 +1,52 @@
+/* GIMP - The GNU Image Manipulation Program
+ * Copyright (C) 1995 Spencer Kimball and Peter Mattis
+ *
+ * gimpoperationcolorbalance.h
+ * Copyright (C) 2012 Michael Natterer <mitch gimp org>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __GIMP_OPERATION_BRIGHTNESS_CONTRAST_H__
+#define __GIMP_OPERATION_BRIGHTNESS_CONTRAST_H__
+
+
+#include "gimpoperationpointfilter.h"
+
+
+#define GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST (gimp_operation_brightness_contrast_get_type ())
+#define GIMP_OPERATION_BRIGHTNESS_CONTRAST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST, GimpOperationBrightnessContrast))
+#define GIMP_OPERATION_BRIGHTNESS_CONTRAST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST, GimpOperationBrightnessContrastClass))
+#define GIMP_IS_OPERATION_BRIGHTNESS_CONTRAST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST))
+#define GIMP_IS_OPERATION_BRIGHTNESS_CONTRAST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST))
+#define GIMP_OPERATION_BRIGHTNESS_CONTRAST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_OPERATION_BRIGHTNESS_CONTRAST, GimpOperationBrightnessContrastClass))
+
+
+typedef struct _GimpOperationBrightnessContrastClass GimpOperationBrightnessContrastClass;
+
+struct _GimpOperationBrightnessContrast
+{
+ GimpOperationPointFilter parent_instance;
+};
+
+struct _GimpOperationBrightnessContrastClass
+{
+ GimpOperationPointFilterClass parent_class;
+};
+
+
+GType gimp_operation_brightness_contrast_get_type (void) G_GNUC_CONST;
+
+
+#endif /* __GIMP_OPERATION_BRIGHTNESS_CONTRAST_H__ */
diff --git a/app/tools/gimpbrightnesscontrasttool.c b/app/tools/gimpbrightnesscontrasttool.c
index be60f12..d372dbc 100644
--- a/app/tools/gimpbrightnesscontrasttool.c
+++ b/app/tools/gimpbrightnesscontrasttool.c
@@ -195,6 +195,11 @@ gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
GObject **config)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
+ GeglNode *node;
+
+ node = g_object_new (GEGL_TYPE_NODE,
+ "operation", "gimp:brightness-contrast",
+ NULL);
bc_tool->config = g_object_new (GIMP_TYPE_BRIGHTNESS_CONTRAST_CONFIG, NULL);
@@ -204,9 +209,11 @@ gimp_brightness_contrast_tool_get_operation (GimpImageMapTool *im_tool,
G_CALLBACK (brightness_contrast_config_notify),
G_OBJECT (bc_tool), 0);
- return g_object_new (GEGL_TYPE_NODE,
- "operation", "gegl:brightness-contrast",
- NULL);
+ gegl_node_set (node,
+ "config", bc_tool->config,
+ NULL);
+
+ return node;
}
static void
@@ -214,9 +221,6 @@ gimp_brightness_contrast_tool_map (GimpImageMapTool *im_tool)
{
GimpBrightnessContrastTool *bc_tool = GIMP_BRIGHTNESS_CONTRAST_TOOL (im_tool);
- gimp_brightness_contrast_config_set_node (bc_tool->config,
- im_tool->operation);
-
brightness_contrast_lut_setup (bc_tool->lut,
bc_tool->config->brightness / 2.0,
bc_tool->config->contrast,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]