Commit 9eaace41 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

renamed gimp_histogram_nchannels() to gimp_histogram_n_channels().

2004-01-13  Michael Natterer  <mitch@gimp.org>

	* app/base/gimphistogram.[ch]: renamed gimp_histogram_nchannels()
	to gimp_histogram_n_channels().

	* app/core/gimpdrawable-histogram.c: removed silly double negation
	logic. Cleanup.

	* app/widgets/gimphistogrameditor.c
	* app/widgets/gimphistogramview.c: adjust the GimpHistogramChannel
	for GRAYA images to make sure we pick alpha from the right slot.

	* app/tools/gimpcurvestool.c
	* app/tools/gimplevelstool.c: removed the same hack here and call
	gimp_histogram_view_set_channel() with the correct enum value.

	* tools/pdbgen/pdb/color.pdb (levels, curves, histogram): fiddle
	with enum values here too so GRAY* drawables produce the correct
	results.

	Fixed precondition checks and set "success" in a uniform way all
	over the place.

	Use gimp_drawable_calculate_histogram() instead of duplicating its
	code here.

	(started with a patch from Pedro Gimeno. Fixes bug #109078)

	* app/pdb/color_cmds.c: regenerated.
parent e1f6aa9e
2004-01-13 Michael Natterer <mitch@gimp.org>
* app/base/gimphistogram.[ch]: renamed gimp_histogram_nchannels()
to gimp_histogram_n_channels().
* app/core/gimpdrawable-histogram.c: removed silly double negation
logic. Cleanup.
* app/widgets/gimphistogrameditor.c
* app/widgets/gimphistogramview.c: adjust the GimpHistogramChannel
for GRAYA images to make sure we pick alpha from the right slot.
* app/tools/gimpcurvestool.c
* app/tools/gimplevelstool.c: removed the same hack here and call
gimp_histogram_view_set_channel() with the correct enum value.
* tools/pdbgen/pdb/color.pdb (levels, curves, histogram): fiddle
with enum values here too so GRAY* drawables produce the correct
results.
Fixed precondition checks and set "success" in a uniform way all
over the place.
Use gimp_drawable_calculate_histogram() instead of duplicating its
code here.
(started with a patch from Pedro Gimeno. Fixes bug #109078)
* app/pdb/color_cmds.c: regenerated.
2004-01-12 Michael Natterer <mitch@gimp.org>
* app/base/gimphistogram.c (gimp_histogram_calculate_sub_region):
......@@ -214,7 +214,7 @@ gimp_histogram_get_channel (GimpHistogram *histogram,
}
gint
gimp_histogram_nchannels (GimpHistogram *histogram)
gimp_histogram_n_channels (GimpHistogram *histogram)
{
g_return_val_if_fail (histogram != NULL, 0);
......
......@@ -53,7 +53,7 @@ gdouble gimp_histogram_get_value (GimpHistogram *histogram,
gdouble gimp_histogram_get_channel (GimpHistogram *histogram,
GimpHistogramChannel channel,
gint bin);
gint gimp_histogram_nchannels (GimpHistogram *histogram);
gint gimp_histogram_n_channels (GimpHistogram *histogram);
#endif /* __GIMP_HISTOGRAM_H__ */
......@@ -22,8 +22,6 @@
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
#include "core-types.h"
#include "base/gimphistogram.h"
......@@ -41,17 +39,16 @@ gimp_drawable_calculate_histogram (GimpDrawable *drawable,
PixelRegion mask;
gint x1, y1, x2, y2;
gint off_x, off_y;
gboolean no_mask;
gboolean have_mask;
g_return_if_fail (drawable != NULL);
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (histogram != NULL);
no_mask = (gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) == FALSE);
pixel_region_init (&region, gimp_drawable_data (drawable), x1, y1,
(x2 - x1), (y2 - y1), FALSE);
have_mask = gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&region, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
if (! no_mask)
if (have_mask)
{
GimpChannel *sel_mask;
GimpImage *gimage;
......
......@@ -109,7 +109,8 @@ brightness_contrast_invoker (Gimp *gimp,
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -129,6 +130,7 @@ brightness_contrast_invoker (Gimp *gimp,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -220,12 +222,17 @@ levels_invoker (Gimp *gimp,
if (success)
{
if (gimp_drawable_is_indexed (drawable) ||
(!gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT
&& channel != GIMP_ALPHA_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
levels_init (&l);
......@@ -254,6 +261,7 @@ levels_invoker (Gimp *gimp,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -343,13 +351,13 @@ levels_auto_invoker (Gimp *gimp,
{
/* Build the histogram */
image = gimp_item_get_image (GIMP_ITEM (drawable));
hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config));
hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config));
gimp_drawable_calculate_histogram (drawable, hist);
/* Calculate the levels */
levels_init (&levels);
levels_auto (&levels, hist, !gimp_drawable_is_gray (drawable));
levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable));
/* Set up the lut */
lut = gimp_lut_new ();
......@@ -362,15 +370,16 @@ levels_auto_invoker (Gimp *gimp,
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_histogram_free (hist);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -428,7 +437,8 @@ posterize_invoker (Gimp *gimp,
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -446,6 +456,7 @@ posterize_invoker (Gimp *gimp,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -665,10 +676,17 @@ curves_spline_invoker (Gimp *gimp,
if (success)
{
if (gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
curves_init (&c);
......@@ -698,6 +716,7 @@ curves_spline_invoker (Gimp *gimp,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -778,10 +797,17 @@ curves_explicit_invoker (Gimp *gimp,
if (success)
{
if (gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
curves_init (&c);
......@@ -796,6 +822,7 @@ curves_explicit_invoker (Gimp *gimp,
/* The application should occur only within selection bounds */
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
......@@ -805,6 +832,7 @@ curves_explicit_invoker (Gimp *gimp,
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -895,7 +923,8 @@ color_balance_invoker (Gimp *gimp,
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
color_balance_init (&cb);
......@@ -996,12 +1025,6 @@ histogram_invoker (Gimp *gimp,
gdouble pixels = 0;
gdouble count = 0;
gdouble percentile = 0;
PixelRegion srcPR, maskPR;
int x1, y1, x2, y2;
GimpHistogram *histogram;
int off_x, off_y;
gboolean no_mask;
GimpChannel *mask;
drawable = (GimpDrawable *) gimp_item_get_by_ID (gimp, args[0].value.pdb_int);
if (! GIMP_IS_DRAWABLE (drawable))
......@@ -1022,32 +1045,21 @@ histogram_invoker (Gimp *gimp,
if (success)
{
if (gimp_drawable_is_indexed (drawable) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
{
/* The information collection should occur only within selection bounds */
no_mask = (gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) == FALSE);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
/* Configure the src from the drawable data */
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
if (success)
{
GimpHistogram *histogram;
/* Configure the mask from the gimage's selection mask */
mask = gimp_image_get_mask (gimp_item_get_image (GIMP_ITEM (drawable)));
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
if (gimp_drawable_is_gray (drawable))
channel = (channel > 0) ? 1 : 0;
/* Apply the image transformation to the pixels */
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
if (no_mask)
gimp_histogram_calculate (histogram, &srcPR, NULL);
else
gimp_histogram_calculate (histogram, &srcPR, &maskPR);
/* Calculate the statistics */
gimp_drawable_calculate_histogram (drawable, histogram);
mean = gimp_histogram_get_mean (histogram, channel,
start_range, end_range);
......@@ -1192,7 +1204,8 @@ hue_saturation_invoker (Gimp *gimp,
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
hue_saturation_init (&hs);
......@@ -1299,7 +1312,8 @@ threshold_invoker (Gimp *gimp,
{
if (gimp_drawable_is_indexed (drawable) || (low_threshold >= high_threshold))
success = FALSE;
else
if (success)
{
tr.color = gimp_drawable_is_rgb (drawable);
tr.low_threshold = low_threshold;
......
......@@ -791,17 +791,12 @@ curves_channel_callback (GtkWidget *widget,
{
gimp_menu_item_update (widget, &c_tool->channel);
if (c_tool->color)
{
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->channel);
}
else
{
c_tool->channel = (c_tool->channel > 1) ? 2 : 1;
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->channel - 1);
}
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (c_tool->graph),
c_tool->channel);
/* FIXME: hack */
if (! c_tool->color)
c_tool->channel = (c_tool->channel > 1) ? 2 : 1;
gimp_int_radio_group_set_active (GTK_RADIO_BUTTON (c_tool->curve_type),
c_tool->curves->curve_type[c_tool->channel]);
......
......@@ -955,17 +955,12 @@ levels_channel_callback (GtkWidget *widget,
{
gimp_menu_item_update (widget, &l_tool->channel);
if (l_tool->color)
{
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
l_tool->channel);
}
else
{
l_tool->channel = (l_tool->channel > 1) ? 2 : 1;
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
l_tool->channel - 1);
}
gimp_histogram_view_set_channel (GIMP_HISTOGRAM_VIEW (l_tool->hist_view),
l_tool->channel);
/* FIXME: hack */
if (! l_tool->color)
l_tool->channel = (l_tool->channel > 1) ? 2 : 1;
levels_update (l_tool, ALL);
}
......
......@@ -355,7 +355,7 @@ gimp_histogram_editor_idle_update (GimpHistogramEditor *editor)
if (editor->drawable && editor->histogram)
{
PixelRegion region;
PixelRegion region;
pixel_region_init (&region, gimp_drawable_data (editor->drawable),
0, 0,
......@@ -375,7 +375,7 @@ static gboolean
gimp_histogram_editor_item_sensitive (GimpHistogramChannel channel,
GimpDrawable *drawable)
{
if (!drawable)
if (! drawable)
return FALSE;
switch (channel)
......@@ -419,31 +419,30 @@ gimp_histogram_editor_info_update (GimpHistogramEditor *editor)
if (hist)
{
gdouble pixels;
gdouble count;
gchar text[12];
GimpHistogramChannel channel = gimp_histogram_view_get_channel (view);
gdouble pixels;
gdouble count;
gchar text[12];
pixels = gimp_histogram_get_count (hist,
view->channel, 0, 255);
count = gimp_histogram_get_count (hist,
view->channel,
view->start, view->end);
/* FIXME: hack */
if (gimp_histogram_n_channels (hist) == 2)
channel = (channel > 0) ? 1 : 0;
pixels = gimp_histogram_get_count (hist, channel, 0, 255);
count = gimp_histogram_get_count (hist, channel, view->start, view->end);
g_snprintf (text, sizeof (text), "%3.1f",
gimp_histogram_get_mean (hist,
view->channel,
gimp_histogram_get_mean (hist, channel,
view->start, view->end));
gtk_label_set_text (GTK_LABEL (editor->labels[0]), text);
g_snprintf (text, sizeof (text), "%3.1f",
gimp_histogram_get_std_dev (hist,
view->channel,
gimp_histogram_get_std_dev (hist, channel,
view->start, view->end));
gtk_label_set_text (GTK_LABEL (editor->labels[1]), text);
g_snprintf (text, sizeof (text), "%3.1f",
(gdouble) gimp_histogram_get_median (hist,
view->channel,
(gdouble) gimp_histogram_get_median (hist, channel,
view->start,
view->end));
gtk_label_set_text (GTK_LABEL (editor->labels[2]), text);
......
......@@ -249,13 +249,14 @@ static gboolean
gimp_histogram_view_expose (GtkWidget *widget,
GdkEventExpose *event)
{
GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
gint x, y;
gint x1, x2;
gint border;
gint width, height;
gdouble max;
gint xstop;
GimpHistogramView *view = GIMP_HISTOGRAM_VIEW (widget);
GimpHistogramChannel channel;
gint x, y;
gint x1, x2;
gint border;
gint width, height;
gdouble max;
gint xstop;
if (! view->histogram)
return FALSE;
......@@ -264,8 +265,14 @@ gimp_histogram_view_expose (GtkWidget *widget,
width = widget->allocation.width - 2 * border;
height = widget->allocation.height - 2 * border;
channel = view->channel;
/* FIXME: hack */
if (gimp_histogram_n_channels (view->histogram) == 2)
channel = (channel > 0) ? 1 : 0;
/* find the maximum value */
max = gimp_histogram_get_maximum (view->histogram, view->channel);
max = gimp_histogram_get_maximum (view->histogram, channel);
switch (view->scale)
{
......@@ -315,7 +322,7 @@ gimp_histogram_view_expose (GtkWidget *widget,
if (! in_selection)
in_selection = ((x1 != 0 || x2 != 255) && x1 <= i && i <= x2);
v = gimp_histogram_get_value (view->histogram, view->channel, i++);
v = gimp_histogram_get_value (view->histogram, channel, i++);
if (v > value)
value = v;
......@@ -473,8 +480,8 @@ gimp_histogram_view_set_histogram (GimpHistogramView *view,
{
view->histogram = histogram;
if (histogram && view->channel >= gimp_histogram_nchannels (histogram))
gimp_histogram_view_set_channel (view, 0);
if (histogram && view->channel >= gimp_histogram_n_channels (histogram))
gimp_histogram_view_set_channel (view, GIMP_HISTOGRAM_VALUE);
}
gtk_widget_queue_draw (GTK_WIDGET (view));
......
......@@ -54,7 +54,8 @@ HELP
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -74,6 +75,7 @@ HELP
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Brightness-Contrast"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -123,12 +125,17 @@ HELP
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable) ||
(!gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT
&& channel != GIMP_ALPHA_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
levels_init (&l);
......@@ -157,6 +164,7 @@ HELP
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -201,13 +209,13 @@ HELP
{
/* Build the histogram */
image = gimp_item_get_image (GIMP_ITEM (drawable));
hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config));
hist = gimp_histogram_new (GIMP_BASE_CONFIG (image->gimp->config));
gimp_drawable_calculate_histogram (drawable, hist);
/* Calculate the levels */
levels_init (&levels);
levels_auto (&levels, hist, !gimp_drawable_is_gray (drawable));
levels_auto (&levels, hist, ! gimp_drawable_is_gray (drawable));
/* Set up the lut */
lut = gimp_lut_new ();
......@@ -220,15 +228,16 @@ HELP
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
x1, y1, (x2 - x1), (y2 - y1), TRUE);
x1, y1, (x2 - x1), (y2 - y1), TRUE);
pixel_regions_process_parallel ((p_func) gimp_lut_process, lut, 2,
&srcPR, &destPR);
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_histogram_free (hist);
gimp_drawable_merge_shadow (drawable, TRUE, _("Levels"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -261,7 +270,8 @@ HELP
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
gimage = gimp_item_get_image (GIMP_ITEM (drawable));
......@@ -279,6 +289,7 @@ HELP
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Posterize"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -404,10 +415,17 @@ HELP
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable) || (num_points & 1) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
curves_init (&c);
......@@ -437,6 +455,7 @@ HELP
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -476,10 +495,17 @@ HELP
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable) || (num_bytes != 256) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
if (success)
{
/* FIXME: hack */
if (gimp_drawable_is_gray (drawable))
channel = (channel > 1) ? 2 : 1;
lut = gimp_lut_new ();
curves_init (&c);
......@@ -494,6 +520,7 @@ HELP
/* The application should occur only within selection bounds */
gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2);
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
pixel_region_init (&destPR, gimp_drawable_shadow (drawable),
......@@ -503,6 +530,7 @@ HELP
&srcPR, &destPR);
gimp_lut_free (lut);
gimp_drawable_merge_shadow (drawable, TRUE, _("Curves"));
gimp_drawable_update (drawable, x1, y1, (x2 - x1), (y2 - y1));
}
......@@ -550,7 +578,8 @@ HELP
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
color_balance_init (&cb);
......@@ -636,39 +665,26 @@ HELP
}
%invoke = (
headers => [ qw("config/gimpbaseconfig.h" "core/gimp.h") ],
vars => [ 'PixelRegion srcPR, maskPR', 'int x1, y1, x2, y2',
'GimpHistogram *histogram', 'int off_x, off_y',
'gboolean no_mask', 'GimpChannel *mask' ],
headers => [ qw("config/gimpbaseconfig.h" "core/gimp.h"
"core/gimpdrawable-histogram.h") ],
code => <<'CODE'
{
if (gimp_drawable_is_indexed (drawable) ||
(gimp_drawable_is_gray (drawable) && channel != GIMP_GRAY_LUT))
(! gimp_drawable_has_alpha (drawable) && channel == GIMP_ALPHA_LUT) ||
(gimp_drawable_is_gray (drawable) &&
channel != GIMP_GRAY_LUT && channel != GIMP_ALPHA_LUT))
success = FALSE;
else
{
/* The information collection should occur only within selection bounds */
no_mask = (gimp_drawable_mask_bounds (drawable, &x1, &y1, &x2, &y2) == FALSE);
gimp_item_offsets (GIMP_ITEM (drawable), &off_x, &off_y);
/* Configure the src from the drawable data */
pixel_region_init (&srcPR, gimp_drawable_data (drawable),
x1, y1, (x2 - x1), (y2 - y1), FALSE);
if (success)
{
GimpHistogram *histogram;
/* Configure the mask from the gimage's selection mask */
mask = gimp_image_get_mask (gimp_item_get_image (GIMP_ITEM (drawable)));
pixel_region_init (&maskPR, gimp_drawable_data (GIMP_DRAWABLE (mask)),
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
if (gimp_drawable_is_gray (drawable))
channel = (channel > 0) ? 1 : 0;
/* Apply the image transformation to the pixels */
histogram = gimp_histogram_new (GIMP_BASE_CONFIG (gimp->config));
if (no_mask)
gimp_histogram_calculate (histogram, &srcPR, NULL);
else
gimp_histogram_calculate (histogram, &srcPR, &maskPR);
/* Calculate the statistics */
gimp_drawable_calculate_histogram (drawable, histogram);
mean = gimp_histogram_get_mean (histogram, channel,
start_range, end_range);
......@@ -723,7 +739,8 @@ HELP
{
if (gimp_drawable_is_indexed (drawable))
success = FALSE;
else
if (success)
{
hue_saturation_init (&hs);
......@@ -783,7 +800,8 @@ HELP
{
if (gimp_drawable_is_indexed (drawable) || (low_threshold >= high_threshold))
success = FALSE;
else
if (success)
{
tr.color = gimp_drawable_is_rgb (drawable);
tr.low_threshold = low_threshold;
......
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