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,
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,
......
......@@ -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,
......
......@@ -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"))
{
......
......@@ -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);
......
......@@ -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);
......
......@@ -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);
......
......@@ -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
......
......@@ -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
......
......@@ -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);
......
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