[gimp] app: add "gboolean gamma_corrected" to gimp_histogram_new()
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: add "gboolean gamma_corrected" to gimp_histogram_new()
- Date: Tue, 11 Jun 2013 23:04:12 +0000 (UTC)
commit 6c97908a9ecb645d2124799a6419c741199db758
Author: Michael Natterer <mitch gimp org>
Date: Wed Jun 12 01:02:25 2013 +0200
app: add "gboolean gamma_corrected" to gimp_histogram_new()
so we can make histograms of the gamma-corrected image data. Pass
TRUE all over the place so the histogram works perceptually. This
needs more thinking...
app/core/gimpdrawable-equalize.c | 2 +-
app/core/gimpdrawable-levels.c | 2 +-
app/core/gimphistogram.c | 31 ++++++++++++++++++++++++-------
app/core/gimphistogram.h | 2 +-
app/pdb/color-cmds.c | 2 +-
app/tools/gimpcurvestool.c | 2 +-
app/tools/gimplevelstool.c | 2 +-
app/tools/gimpthresholdtool.c | 2 +-
app/widgets/gimphistogrameditor.c | 2 +-
9 files changed, 32 insertions(+), 15 deletions(-)
---
diff --git a/app/core/gimpdrawable-equalize.c b/app/core/gimpdrawable-equalize.c
index ff481e7..0998358 100644
--- a/app/core/gimpdrawable-equalize.c
+++ b/app/core/gimpdrawable-equalize.c
@@ -40,7 +40,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
- hist = gimp_histogram_new ();
+ hist = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, hist);
equalize = gegl_node_new_child (NULL,
diff --git a/app/core/gimpdrawable-levels.c b/app/core/gimpdrawable-levels.c
index 38da9f0..352382f 100644
--- a/app/core/gimpdrawable-levels.c
+++ b/app/core/gimpdrawable-levels.c
@@ -52,7 +52,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL);
- histogram = gimp_histogram_new ();
+ histogram = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, histogram);
gimp_levels_config_stretch (config, histogram,
diff --git a/app/core/gimphistogram.c b/app/core/gimphistogram.c
index f87a8b1..ce0be31 100644
--- a/app/core/gimphistogram.c
+++ b/app/core/gimphistogram.c
@@ -42,6 +42,7 @@ enum
struct _GimpHistogramPrivate
{
+ gboolean gamma_correct;
gint n_channels;
gint n_bins;
gdouble *values;
@@ -185,9 +186,13 @@ gimp_histogram_get_memsize (GimpObject *object,
/* public functions */
GimpHistogram *
-gimp_histogram_new (void)
+gimp_histogram_new (gboolean gamma_correct)
{
- return g_object_new (GIMP_TYPE_HISTOGRAM, NULL);
+ GimpHistogram *histogram = g_object_new (GIMP_TYPE_HISTOGRAM, NULL);
+
+ histogram->priv->gamma_correct = gamma_correct;
+
+ return histogram;
}
/**
@@ -206,7 +211,7 @@ gimp_histogram_duplicate (GimpHistogram *histogram)
g_return_val_if_fail (GIMP_IS_HISTOGRAM (histogram), NULL);
- dup = gimp_histogram_new ();
+ dup = gimp_histogram_new (histogram->priv->gamma_correct);
dup->priv->n_channels = histogram->priv->n_channels;
dup->priv->n_bins = histogram->priv->n_bins;
@@ -257,7 +262,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
if (model == babl_model ("Y"))
{
- format = babl_format ("Y float");
+ if (priv->gamma_correct)
+ format = babl_format ("Y' float");
+ else
+ format = babl_format ("Y float");
}
else if (model == babl_model ("Y'"))
{
@@ -265,7 +273,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
}
else if (model == babl_model ("YA"))
{
- format = babl_format ("YA float");
+ if (priv->gamma_correct)
+ format = babl_format ("Y'A float");
+ else
+ format = babl_format ("YA float");
}
else if (model == babl_model ("Y'A"))
{
@@ -273,7 +284,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
}
else if (model == babl_model ("RGB"))
{
- format = babl_format ("RGB float");
+ if (priv->gamma_correct)
+ format = babl_format ("R'G'B' float");
+ else
+ format = babl_format ("RGB float");
}
else if (model == babl_model ("R'G'B'"))
{
@@ -281,7 +295,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
}
else if (model == babl_model ("RGBA"))
{
- format = babl_format ("RGBA float");
+ if (priv->gamma_correct)
+ format = babl_format ("R'G'B'A float");
+ else
+ format = babl_format ("RGBA float");
}
else if (model == babl_model ("R'G'B'A"))
{
diff --git a/app/core/gimphistogram.h b/app/core/gimphistogram.h
index 7f8173c..c8657a2 100644
--- a/app/core/gimphistogram.h
+++ b/app/core/gimphistogram.h
@@ -50,7 +50,7 @@ struct _GimpHistogramClass
GType gimp_histogram_get_type (void) G_GNUC_CONST;
-GimpHistogram * gimp_histogram_new (void);
+GimpHistogram * gimp_histogram_new (gboolean gamma_correct);
GimpHistogram * gimp_histogram_duplicate (GimpHistogram *histogram);
diff --git a/app/pdb/color-cmds.c b/app/pdb/color-cmds.c
index 45c4da1..9320011 100644
--- a/app/pdb/color-cmds.c
+++ b/app/pdb/color-cmds.c
@@ -623,7 +623,7 @@ histogram_invoker (GimpProcedure *procedure,
if (success)
{
- GimpHistogram *histogram = gimp_histogram_new ();
+ GimpHistogram *histogram = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, histogram);
diff --git a/app/tools/gimpcurvestool.c b/app/tools/gimpcurvestool.c
index 24145c3..315a4a7 100644
--- a/app/tools/gimpcurvestool.c
+++ b/app/tools/gimpcurvestool.c
@@ -212,7 +212,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
curves_menu_sensitivity, drawable, NULL);
- histogram = gimp_histogram_new ();
+ histogram = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, histogram);
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
histogram);
diff --git a/app/tools/gimplevelstool.c b/app/tools/gimplevelstool.c
index adb24cc..9338a7c 100644
--- a/app/tools/gimplevelstool.c
+++ b/app/tools/gimplevelstool.c
@@ -177,7 +177,7 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
static void
gimp_levels_tool_init (GimpLevelsTool *tool)
{
- tool->histogram = gimp_histogram_new ();
+ tool->histogram = gimp_histogram_new (TRUE);
}
static void
diff --git a/app/tools/gimpthresholdtool.c b/app/tools/gimpthresholdtool.c
index 220a18b..e3d48a1 100644
--- a/app/tools/gimpthresholdtool.c
+++ b/app/tools/gimpthresholdtool.c
@@ -116,7 +116,7 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
static void
gimp_threshold_tool_init (GimpThresholdTool *t_tool)
{
- t_tool->histogram = gimp_histogram_new ();
+ t_tool->histogram = gimp_histogram_new (TRUE);
}
static void
diff --git a/app/widgets/gimphistogrameditor.c b/app/widgets/gimphistogrameditor.c
index 54c8193..b2dcde3 100644
--- a/app/widgets/gimphistogrameditor.c
+++ b/app/widgets/gimphistogrameditor.c
@@ -280,7 +280,7 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
if (image)
{
- editor->histogram = gimp_histogram_new ();
+ editor->histogram = gimp_histogram_new (TRUE);
gimp_histogram_view_set_histogram (view, editor->histogram);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]