Commit 6c97908a authored by Michael Natterer's avatar Michael Natterer 😴

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...
parent 96d1a939
...@@ -40,7 +40,7 @@ gimp_drawable_equalize (GimpDrawable *drawable, ...@@ -40,7 +40,7 @@ gimp_drawable_equalize (GimpDrawable *drawable,
g_return_if_fail (GIMP_IS_DRAWABLE (drawable)); g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (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); gimp_drawable_calculate_histogram (drawable, hist);
equalize = gegl_node_new_child (NULL, equalize = gegl_node_new_child (NULL,
......
...@@ -52,7 +52,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable, ...@@ -52,7 +52,7 @@ gimp_drawable_levels_stretch (GimpDrawable *drawable,
config = g_object_new (GIMP_TYPE_LEVELS_CONFIG, NULL); 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_drawable_calculate_histogram (drawable, histogram);
gimp_levels_config_stretch (config, histogram, gimp_levels_config_stretch (config, histogram,
......
...@@ -42,6 +42,7 @@ enum ...@@ -42,6 +42,7 @@ enum
struct _GimpHistogramPrivate struct _GimpHistogramPrivate
{ {
gboolean gamma_correct;
gint n_channels; gint n_channels;
gint n_bins; gint n_bins;
gdouble *values; gdouble *values;
...@@ -185,9 +186,13 @@ gimp_histogram_get_memsize (GimpObject *object, ...@@ -185,9 +186,13 @@ gimp_histogram_get_memsize (GimpObject *object,
/* public functions */ /* public functions */
GimpHistogram * 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) ...@@ -206,7 +211,7 @@ gimp_histogram_duplicate (GimpHistogram *histogram)
g_return_val_if_fail (GIMP_IS_HISTOGRAM (histogram), NULL); 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_channels = histogram->priv->n_channels;
dup->priv->n_bins = histogram->priv->n_bins; dup->priv->n_bins = histogram->priv->n_bins;
...@@ -257,7 +262,10 @@ gimp_histogram_calculate (GimpHistogram *histogram, ...@@ -257,7 +262,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
if (model == babl_model ("Y")) 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'")) else if (model == babl_model ("Y'"))
{ {
...@@ -265,7 +273,10 @@ gimp_histogram_calculate (GimpHistogram *histogram, ...@@ -265,7 +273,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
} }
else if (model == babl_model ("YA")) 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")) else if (model == babl_model ("Y'A"))
{ {
...@@ -273,7 +284,10 @@ gimp_histogram_calculate (GimpHistogram *histogram, ...@@ -273,7 +284,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
} }
else if (model == babl_model ("RGB")) 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'")) else if (model == babl_model ("R'G'B'"))
{ {
...@@ -281,7 +295,10 @@ gimp_histogram_calculate (GimpHistogram *histogram, ...@@ -281,7 +295,10 @@ gimp_histogram_calculate (GimpHistogram *histogram,
} }
else if (model == babl_model ("RGBA")) 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")) else if (model == babl_model ("R'G'B'A"))
{ {
......
...@@ -50,7 +50,7 @@ struct _GimpHistogramClass ...@@ -50,7 +50,7 @@ struct _GimpHistogramClass
GType gimp_histogram_get_type (void) G_GNUC_CONST; 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); GimpHistogram * gimp_histogram_duplicate (GimpHistogram *histogram);
......
...@@ -623,7 +623,7 @@ histogram_invoker (GimpProcedure *procedure, ...@@ -623,7 +623,7 @@ histogram_invoker (GimpProcedure *procedure,
if (success) if (success)
{ {
GimpHistogram *histogram = gimp_histogram_new (); GimpHistogram *histogram = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, histogram); gimp_drawable_calculate_histogram (drawable, histogram);
......
...@@ -212,7 +212,7 @@ gimp_curves_tool_initialize (GimpTool *tool, ...@@ -212,7 +212,7 @@ gimp_curves_tool_initialize (GimpTool *tool,
gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (c_tool->channel_menu), gimp_int_combo_box_set_sensitivity (GIMP_INT_COMBO_BOX (c_tool->channel_menu),
curves_menu_sensitivity, drawable, NULL); curves_menu_sensitivity, drawable, NULL);
histogram = gimp_histogram_new (); histogram = gimp_histogram_new (TRUE);
gimp_drawable_calculate_histogram (drawable, histogram); gimp_drawable_calculate_histogram (drawable, histogram);
gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph), gimp_histogram_view_set_background (GIMP_HISTOGRAM_VIEW (c_tool->graph),
histogram); histogram);
......
...@@ -177,7 +177,7 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass) ...@@ -177,7 +177,7 @@ gimp_levels_tool_class_init (GimpLevelsToolClass *klass)
static void static void
gimp_levels_tool_init (GimpLevelsTool *tool) gimp_levels_tool_init (GimpLevelsTool *tool)
{ {
tool->histogram = gimp_histogram_new (); tool->histogram = gimp_histogram_new (TRUE);
} }
static void static void
......
...@@ -116,7 +116,7 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass) ...@@ -116,7 +116,7 @@ gimp_threshold_tool_class_init (GimpThresholdToolClass *klass)
static void static void
gimp_threshold_tool_init (GimpThresholdTool *t_tool) gimp_threshold_tool_init (GimpThresholdTool *t_tool)
{ {
t_tool->histogram = gimp_histogram_new (); t_tool->histogram = gimp_histogram_new (TRUE);
} }
static void static void
......
...@@ -280,7 +280,7 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor, ...@@ -280,7 +280,7 @@ gimp_histogram_editor_set_image (GimpImageEditor *image_editor,
if (image) if (image)
{ {
editor->histogram = gimp_histogram_new (); editor->histogram = gimp_histogram_new (TRUE);
gimp_histogram_view_set_histogram (view, editor->histogram); gimp_histogram_view_set_histogram (view, editor->histogram);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment