Histogram cleanup:
2002-09-07 Michael Natterer <mitch@gimp.org> Histogram cleanup: * app/base/gimphistogram.c: Added g_return_if_fail() to all public functions, reordered stuff, cleanup (no logic changed). * app/widgets/Makefile.am * app/widgets/widgets-types.h * app/widgets/gimphistogrambox.[ch]: new widget containing a GimpHistogramView and two range spinbuttons (as known from the threshold tool). Users only need to connect to the histogram view's "range_changed" signal. The spinbuttons are handled internally. * app/widgets/gimphistogramview.[ch]: define it's default size in the header. Make sure "start" is always smaller than "end". Emit "range_changed" in gimp_histogram_view_set_range(). * app/tools/gimplevelstool.c: changed accordingly. * app/tools/gimpthresholdtool.[ch]: removed the code which did the same and use the new widget. * app/tools/gimphistogramtool.[ch]: ditto. Removed the "intensity" info label. Cleanup.
This commit is contained in:

committed by
Michael Natterer

parent
4f1753cae2
commit
f54912e108
27
ChangeLog
27
ChangeLog
@ -1,3 +1,30 @@
|
|||||||
|
2002-09-07 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
|
Histogram cleanup:
|
||||||
|
|
||||||
|
* app/base/gimphistogram.c: Added g_return_if_fail() to all public
|
||||||
|
functions, reordered stuff, cleanup (no logic changed).
|
||||||
|
|
||||||
|
* app/widgets/Makefile.am
|
||||||
|
* app/widgets/widgets-types.h
|
||||||
|
* app/widgets/gimphistogrambox.[ch]: new widget containing a
|
||||||
|
GimpHistogramView and two range spinbuttons (as known from the
|
||||||
|
threshold tool). Users only need to connect to the histogram
|
||||||
|
view's "range_changed" signal. The spinbuttons are handled
|
||||||
|
internally.
|
||||||
|
|
||||||
|
* app/widgets/gimphistogramview.[ch]: define it's default size in
|
||||||
|
the header. Make sure "start" is always smaller than "end". Emit
|
||||||
|
"range_changed" in gimp_histogram_view_set_range().
|
||||||
|
|
||||||
|
* app/tools/gimplevelstool.c: changed accordingly.
|
||||||
|
|
||||||
|
* app/tools/gimpthresholdtool.[ch]: removed the code which
|
||||||
|
did the same and use the new widget.
|
||||||
|
|
||||||
|
* app/tools/gimphistogramtool.[ch]: ditto. Removed the "intensity"
|
||||||
|
info label. Cleanup.
|
||||||
|
|
||||||
2002-09-07 Michael Natterer <mitch@gimp.org>
|
2002-09-07 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/gui/file-new-dialog.c
|
* app/gui/file-new-dialog.c
|
||||||
|
@ -51,6 +51,18 @@ struct _GimpHistogram
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_histogram_alloc_values (GimpHistogram *histogram,
|
||||||
|
gint bytes);
|
||||||
|
static void gimp_histogram_free_values (GimpHistogram *histogram);
|
||||||
|
static void gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
||||||
|
PixelRegion *region,
|
||||||
|
PixelRegion *mask);
|
||||||
|
|
||||||
|
|
||||||
|
/* public functions */
|
||||||
|
|
||||||
GimpHistogram *
|
GimpHistogram *
|
||||||
gimp_histogram_new (void)
|
gimp_histogram_new (void)
|
||||||
{
|
{
|
||||||
@ -72,17 +84,246 @@ gimp_histogram_new (void)
|
|||||||
|
|
||||||
void
|
void
|
||||||
gimp_histogram_free (GimpHistogram *histogram)
|
gimp_histogram_free (GimpHistogram *histogram)
|
||||||
|
{
|
||||||
|
g_return_if_fail (histogram != NULL);
|
||||||
|
|
||||||
|
gimp_histogram_free_values (histogram);
|
||||||
|
g_free (histogram);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_histogram_calculate (GimpHistogram *histogram,
|
||||||
|
PixelRegion *region,
|
||||||
|
PixelRegion *mask)
|
||||||
|
{
|
||||||
|
gint i, j;
|
||||||
|
#ifdef ENABLE_MP
|
||||||
|
gint k;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
g_return_if_fail (histogram != NULL);
|
||||||
|
g_return_if_fail (region != NULL);
|
||||||
|
|
||||||
|
gimp_histogram_alloc_values (histogram, region->bytes);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MP
|
||||||
|
pthread_mutex_init (&histogram->mutex, NULL);
|
||||||
|
histogram->tmp_slots = g_new0 (gchar, base_config->num_processors);
|
||||||
|
histogram->tmp_values = g_new0 (gdouble **, base_config->num_processors);
|
||||||
|
|
||||||
|
for (i = 0; i < base_config->num_processors; i++)
|
||||||
|
{
|
||||||
|
histogram->tmp_values[i] = g_new0 (double *, histogram->n_channels);
|
||||||
|
histogram->tmp_slots[i] = 0;
|
||||||
|
|
||||||
|
for (j = 0; j < histogram->n_channels; j++)
|
||||||
|
{
|
||||||
|
histogram->tmp_values[i][j] = g_new0 (gdouble, 256);
|
||||||
|
|
||||||
|
for (k = 0; k < 256; k++)
|
||||||
|
histogram->tmp_values[i][j][k] = 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (i = 0; i < histogram->n_channels; i++)
|
||||||
|
for (j = 0; j < 256; j++)
|
||||||
|
histogram->values[i][j] = 0.0;
|
||||||
|
|
||||||
|
pixel_regions_process_parallel ((p_func)gimp_histogram_calculate_sub_region,
|
||||||
|
histogram, 2, region, mask);
|
||||||
|
|
||||||
|
#ifdef ENABLE_MP
|
||||||
|
/* add up all the tmp buffers and free their memmory */
|
||||||
|
for (i = 0; i < base_config->num_processors; i++)
|
||||||
|
{
|
||||||
|
for (j = 0; j < histogram->n_channels; j++)
|
||||||
|
{
|
||||||
|
for (k = 0; k < 256; k++)
|
||||||
|
histogram->values[j][k] += histogram->tmp_values[i][j][k];
|
||||||
|
g_free (histogram->tmp_values[i][j]);
|
||||||
|
}
|
||||||
|
g_free (histogram->tmp_values[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_free (histogram->tmp_values);
|
||||||
|
g_free (histogram->tmp_slots);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_maximum (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel)
|
||||||
|
{
|
||||||
|
gdouble max = 0.0;
|
||||||
|
gint x;
|
||||||
|
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
for (x = 0; x < 256; x++)
|
||||||
|
if (histogram->values[channel][x] > max)
|
||||||
|
max = histogram->values[channel][x];
|
||||||
|
|
||||||
|
return max;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_value (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel,
|
||||||
|
gint bin)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
if (channel < histogram->n_channels && bin >= 0 && bin < 256)
|
||||||
|
return histogram->values[channel][bin];
|
||||||
|
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_channel (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel,
|
||||||
|
gint bin)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
if (histogram->n_channels > 3)
|
||||||
|
return gimp_histogram_get_value (histogram, channel + 1, bin);
|
||||||
|
else
|
||||||
|
return gimp_histogram_get_value (histogram, channel , bin);
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gimp_histogram_nchannels (GimpHistogram *histogram)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0);
|
||||||
|
|
||||||
|
return histogram->n_channels - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_count (GimpHistogram *histogram,
|
||||||
|
gint start,
|
||||||
|
gint end)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gdouble count = 0.0;
|
||||||
|
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++)
|
||||||
|
count += histogram->values[0][i];
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_mean (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel,
|
||||||
|
gint start,
|
||||||
|
gint end)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gdouble mean = 0.0;
|
||||||
|
gdouble count;
|
||||||
|
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++)
|
||||||
|
mean += i * histogram->values[channel][i];
|
||||||
|
|
||||||
|
count = gimp_histogram_get_count (histogram, start, end);
|
||||||
|
|
||||||
|
if (count > 0.0)
|
||||||
|
return mean / count;
|
||||||
|
|
||||||
|
return mean;
|
||||||
|
}
|
||||||
|
|
||||||
|
gint
|
||||||
|
gimp_histogram_get_median (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel,
|
||||||
|
gint start,
|
||||||
|
gint end)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gdouble sum = 0.0;
|
||||||
|
gdouble count;
|
||||||
|
|
||||||
|
g_return_val_if_fail (histogram != NULL, -1);
|
||||||
|
|
||||||
|
count = gimp_histogram_get_count (histogram, start, end);
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++)
|
||||||
|
{
|
||||||
|
sum += histogram->values[channel][i];
|
||||||
|
|
||||||
|
if (sum * 2 > count)
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
gdouble
|
||||||
|
gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
||||||
|
GimpHistogramChannel channel,
|
||||||
|
gint start,
|
||||||
|
gint end)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
gdouble dev = 0.0;
|
||||||
|
gdouble count;
|
||||||
|
gdouble mean;
|
||||||
|
|
||||||
|
g_return_val_if_fail (histogram != NULL, 0.0);
|
||||||
|
|
||||||
|
mean = gimp_histogram_get_mean (histogram, channel, start, end);
|
||||||
|
count = gimp_histogram_get_count (histogram, start, end);
|
||||||
|
|
||||||
|
if (count == 0.0)
|
||||||
|
count = 1.0;
|
||||||
|
|
||||||
|
for (i = start; i <= end; i++)
|
||||||
|
dev += gimp_histogram_get_value (histogram, channel, i) *
|
||||||
|
(i - mean) * (i - mean);
|
||||||
|
|
||||||
|
return sqrt (dev / count);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* private functions */
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_alloc_values (GimpHistogram *histogram,
|
||||||
|
gint bytes)
|
||||||
|
{
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
if (bytes + 1 != histogram->n_channels)
|
||||||
|
{
|
||||||
|
gimp_histogram_free_values (histogram);
|
||||||
|
|
||||||
|
histogram->n_channels = bytes + 1;
|
||||||
|
histogram->values = g_new0 (gdouble *, histogram->n_channels);
|
||||||
|
|
||||||
|
for (i = 0; i < histogram->n_channels; i++)
|
||||||
|
histogram->values[i] = g_new (double, 256);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_free_values (GimpHistogram *histogram)
|
||||||
{
|
{
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (histogram->values)
|
if (histogram->values)
|
||||||
{
|
{
|
||||||
for (i = 0; i < histogram->n_channels; i++)
|
for (i = 0; i < histogram->n_channels; i++)
|
||||||
g_free (histogram->values[i]);
|
g_free (histogram->values[i]);
|
||||||
g_free (histogram->values);
|
g_free (histogram->values);
|
||||||
|
histogram->values = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (histogram);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -262,207 +503,3 @@ gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
|
|||||||
pthread_mutex_unlock (&histogram->mutex);
|
pthread_mutex_unlock (&histogram->mutex);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gimp_histogram_alloc (GimpHistogram *histogram,
|
|
||||||
gint bytes)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
|
|
||||||
if (bytes + 1 != histogram->n_channels)
|
|
||||||
{
|
|
||||||
if (histogram->values)
|
|
||||||
{
|
|
||||||
for (i = 0; i < histogram->n_channels; i++)
|
|
||||||
g_free (histogram->values[i]);
|
|
||||||
g_free (histogram->values);
|
|
||||||
}
|
|
||||||
|
|
||||||
histogram->n_channels = bytes + 1;
|
|
||||||
histogram->values = g_new0 (gdouble *, histogram->n_channels);
|
|
||||||
|
|
||||||
for (i = 0; i < histogram->n_channels; i++)
|
|
||||||
histogram->values[i] = g_new (double, 256);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_histogram_calculate (GimpHistogram *histogram,
|
|
||||||
PixelRegion *region,
|
|
||||||
PixelRegion *mask)
|
|
||||||
{
|
|
||||||
gint i, j;
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
gint k;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
gimp_histogram_alloc (histogram, region->bytes);
|
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
pthread_mutex_init (&histogram->mutex, NULL);
|
|
||||||
histogram->tmp_slots = g_new0 (gchar, base_config->num_processors);
|
|
||||||
histogram->tmp_values = g_new0 (gdouble **, base_config->num_processors);
|
|
||||||
|
|
||||||
for (i = 0; i < base_config->num_processors; i++)
|
|
||||||
{
|
|
||||||
histogram->tmp_values[i] = g_new0 (double *, histogram->n_channels);
|
|
||||||
histogram->tmp_slots[i] = 0;
|
|
||||||
|
|
||||||
for (j = 0; j < histogram->n_channels; j++)
|
|
||||||
{
|
|
||||||
histogram->tmp_values[i][j] = g_new0 (gdouble, 256);
|
|
||||||
|
|
||||||
for (k = 0; k < 256; k++)
|
|
||||||
histogram->tmp_values[i][j][k] = 0.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (i = 0; i < histogram->n_channels; i++)
|
|
||||||
for (j = 0; j < 256; j++)
|
|
||||||
histogram->values[i][j] = 0.0;
|
|
||||||
|
|
||||||
pixel_regions_process_parallel ((p_func)gimp_histogram_calculate_sub_region,
|
|
||||||
histogram, 2, region, mask);
|
|
||||||
|
|
||||||
#ifdef ENABLE_MP
|
|
||||||
/* add up all the tmp buffers and free their memmory */
|
|
||||||
for (i = 0; i < base_config->num_processors; i++)
|
|
||||||
{
|
|
||||||
for (j = 0; j < histogram->n_channels; j++)
|
|
||||||
{
|
|
||||||
for (k = 0; k < 256; k++)
|
|
||||||
histogram->values[j][k] += histogram->tmp_values[i][j][k];
|
|
||||||
g_free (histogram->tmp_values[i][j]);
|
|
||||||
}
|
|
||||||
g_free (histogram->tmp_values[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_free (histogram->tmp_values);
|
|
||||||
g_free (histogram->tmp_slots);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_maximum (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel)
|
|
||||||
{
|
|
||||||
gdouble max = 0.0;
|
|
||||||
gint x;
|
|
||||||
|
|
||||||
for (x = 0; x < 256; x++)
|
|
||||||
if (histogram->values[channel][x] > max)
|
|
||||||
max = histogram->values[channel][x];
|
|
||||||
|
|
||||||
return max;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_value (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel,
|
|
||||||
gint bin)
|
|
||||||
{
|
|
||||||
if (channel < histogram->n_channels && bin >= 0 && bin < 256)
|
|
||||||
return histogram->values[channel][bin];
|
|
||||||
|
|
||||||
return 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_channel (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel,
|
|
||||||
gint bin)
|
|
||||||
{
|
|
||||||
if (histogram->n_channels > 3)
|
|
||||||
return gimp_histogram_get_value (histogram, channel + 1, bin);
|
|
||||||
else
|
|
||||||
return gimp_histogram_get_value (histogram, channel , bin);
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gimp_histogram_nchannels (GimpHistogram *histogram)
|
|
||||||
{
|
|
||||||
return histogram->n_channels - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_count (GimpHistogram *histogram,
|
|
||||||
gint start,
|
|
||||||
gint end)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
gdouble count = 0.0;
|
|
||||||
|
|
||||||
for (i = start; i <= end; i++)
|
|
||||||
count += histogram->values[0][i];
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_mean (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel,
|
|
||||||
gint start,
|
|
||||||
gint end)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
gdouble mean = 0.0;
|
|
||||||
gdouble count;
|
|
||||||
|
|
||||||
for (i = start; i <= end; i++)
|
|
||||||
mean += i * histogram->values[channel][i];
|
|
||||||
|
|
||||||
count = gimp_histogram_get_count (histogram, start, end);
|
|
||||||
|
|
||||||
if (count > 0.0)
|
|
||||||
return mean / count;
|
|
||||||
|
|
||||||
return mean;
|
|
||||||
}
|
|
||||||
|
|
||||||
gint
|
|
||||||
gimp_histogram_get_median (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel,
|
|
||||||
gint start,
|
|
||||||
gint end)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
gdouble sum = 0.0;
|
|
||||||
gdouble count;
|
|
||||||
|
|
||||||
count = gimp_histogram_get_count (histogram, start, end);
|
|
||||||
|
|
||||||
for (i = start; i <= end; i++)
|
|
||||||
{
|
|
||||||
sum += histogram->values[channel][i];
|
|
||||||
|
|
||||||
if (sum * 2 > count)
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
gdouble
|
|
||||||
gimp_histogram_get_std_dev (GimpHistogram *histogram,
|
|
||||||
GimpHistogramChannel channel,
|
|
||||||
gint start,
|
|
||||||
gint end)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
gdouble dev = 0.0;
|
|
||||||
gdouble count;
|
|
||||||
gdouble mean;
|
|
||||||
|
|
||||||
mean = gimp_histogram_get_mean (histogram, channel, start, end);
|
|
||||||
count = gimp_histogram_get_count (histogram, start, end);
|
|
||||||
|
|
||||||
if (count == 0.0)
|
|
||||||
count = 1.0;
|
|
||||||
|
|
||||||
for (i = start; i <= end; i++)
|
|
||||||
dev += gimp_histogram_get_value (histogram, channel, i) *
|
|
||||||
(i - mean) * (i - mean);
|
|
||||||
|
|
||||||
return sqrt (dev / count);
|
|
||||||
}
|
|
||||||
|
@ -38,6 +38,7 @@
|
|||||||
#include "core/gimptoolinfo.h"
|
#include "core/gimptoolinfo.h"
|
||||||
|
|
||||||
#include "widgets/gimpenummenu.h"
|
#include "widgets/gimpenummenu.h"
|
||||||
|
#include "widgets/gimphistogrambox.h"
|
||||||
#include "widgets/gimphistogramview.h"
|
#include "widgets/gimphistogramview.h"
|
||||||
#include "widgets/gimpviewabledialog.h"
|
#include "widgets/gimpviewabledialog.h"
|
||||||
|
|
||||||
@ -51,8 +52,8 @@
|
|||||||
#include "libgimp/gimpintl.h"
|
#include "libgimp/gimpintl.h"
|
||||||
|
|
||||||
|
|
||||||
#define TEXT_WIDTH 45
|
#define TEXT_WIDTH 45
|
||||||
#define GRADIENT_HEIGHT 15
|
#define GRADIENT_HEIGHT 15
|
||||||
|
|
||||||
|
|
||||||
typedef struct _HistogramToolDialog HistogramToolDialog;
|
typedef struct _HistogramToolDialog HistogramToolDialog;
|
||||||
@ -61,9 +62,9 @@ struct _HistogramToolDialog
|
|||||||
{
|
{
|
||||||
GtkWidget *shell;
|
GtkWidget *shell;
|
||||||
|
|
||||||
GtkWidget *info_labels[7];
|
GtkWidget *info_labels[6];
|
||||||
GtkWidget *channel_menu;
|
GtkWidget *channel_menu;
|
||||||
GimpHistogramView *histogram;
|
GimpHistogramBox *histogram_box;
|
||||||
GimpHistogram *hist;
|
GimpHistogram *hist;
|
||||||
GtkWidget *gradient;
|
GtkWidget *gradient;
|
||||||
|
|
||||||
@ -146,18 +147,18 @@ gimp_histogram_tool_get_type (void)
|
|||||||
static const GTypeInfo tool_info =
|
static const GTypeInfo tool_info =
|
||||||
{
|
{
|
||||||
sizeof (GimpHistogramToolClass),
|
sizeof (GimpHistogramToolClass),
|
||||||
(GBaseInitFunc) NULL,
|
(GBaseInitFunc) NULL,
|
||||||
(GBaseFinalizeFunc) NULL,
|
(GBaseFinalizeFunc) NULL,
|
||||||
(GClassInitFunc) gimp_histogram_tool_class_init,
|
(GClassInitFunc) gimp_histogram_tool_class_init,
|
||||||
NULL, /* class_finalize */
|
NULL, /* class_finalize */
|
||||||
NULL, /* class_data */
|
NULL, /* class_data */
|
||||||
sizeof (GimpHistogramTool),
|
sizeof (GimpHistogramTool),
|
||||||
0, /* n_preallocs */
|
0, /* n_preallocs */
|
||||||
(GInstanceInitFunc) gimp_histogram_tool_init,
|
(GInstanceInitFunc) gimp_histogram_tool_init,
|
||||||
};
|
};
|
||||||
|
|
||||||
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
tool_type = g_type_register_static (GIMP_TYPE_IMAGE_MAP_TOOL,
|
||||||
"GimpHistogramTool",
|
"GimpHistogramTool",
|
||||||
&tool_info, 0);
|
&tool_info, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +190,13 @@ gimp_histogram_tool_initialize (GimpTool *tool,
|
|||||||
GimpDrawable *drawable;
|
GimpDrawable *drawable;
|
||||||
PixelRegion PR;
|
PixelRegion PR;
|
||||||
|
|
||||||
|
if (! gdisp)
|
||||||
|
{
|
||||||
|
if (histogram_dialog)
|
||||||
|
histogram_tool_close_callback (NULL, histogram_dialog);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
|
if (gimp_drawable_is_indexed (gimp_image_active_drawable (gdisp->gimage)))
|
||||||
{
|
{
|
||||||
g_message (_("Histogram does not operate on indexed drawables."));
|
g_message (_("Histogram does not operate on indexed drawables."));
|
||||||
@ -223,9 +231,10 @@ gimp_histogram_tool_initialize (GimpTool *tool,
|
|||||||
FALSE);
|
FALSE);
|
||||||
gimp_histogram_calculate (histogram_dialog->hist, &PR, NULL);
|
gimp_histogram_calculate (histogram_dialog->hist, &PR, NULL);
|
||||||
|
|
||||||
gimp_histogram_view_update (histogram_dialog->histogram,
|
gimp_histogram_view_update (histogram_dialog->histogram_box->histogram,
|
||||||
histogram_dialog->hist);
|
histogram_dialog->hist);
|
||||||
gimp_histogram_view_range (histogram_dialog->histogram, 0, 255);
|
gimp_histogram_view_set_range (histogram_dialog->histogram_box->histogram,
|
||||||
|
0, 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -243,7 +252,7 @@ gimp_histogram_tool_control (GimpTool *tool,
|
|||||||
|
|
||||||
case HALT:
|
case HALT:
|
||||||
if (histogram_dialog)
|
if (histogram_dialog)
|
||||||
histogram_tool_close_callback (NULL, (gpointer) histogram_dialog);
|
histogram_tool_close_callback (NULL, histogram_dialog);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@ -312,20 +321,13 @@ histogram_tool_dialog_update (HistogramToolDialog *htd,
|
|||||||
g_snprintf (text, sizeof (text), "%8.1f", htd->pixels);
|
g_snprintf (text, sizeof (text), "%8.1f", htd->pixels);
|
||||||
gtk_label_set_text (GTK_LABEL (htd->info_labels[3]), text);
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[3]), text);
|
||||||
|
|
||||||
/* intensity */
|
|
||||||
if (start == end)
|
|
||||||
g_snprintf (text, sizeof (text), "%d", start);
|
|
||||||
else
|
|
||||||
g_snprintf (text, sizeof (text), "%d..%d", start, end);
|
|
||||||
gtk_label_set_text (GTK_LABEL (htd->info_labels[4]), text);
|
|
||||||
|
|
||||||
/* count */
|
/* count */
|
||||||
g_snprintf (text, sizeof (text), "%8.1f", htd->count);
|
g_snprintf (text, sizeof (text), "%8.1f", htd->count);
|
||||||
gtk_label_set_text (GTK_LABEL (htd->info_labels[5]), text);
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[4]), text);
|
||||||
|
|
||||||
/* percentile */
|
/* percentile */
|
||||||
g_snprintf (text, sizeof (text), "%2.2f", htd->percentile * 100);
|
g_snprintf (text, sizeof (text), "%2.2f", htd->percentile * 100);
|
||||||
gtk_label_set_text (GTK_LABEL (htd->info_labels[6]), text);
|
gtk_label_set_text (GTK_LABEL (htd->info_labels[5]), text);
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************/
|
/***************************/
|
||||||
@ -350,7 +352,6 @@ histogram_tool_dialog_new (GimpToolInfo *tool_info)
|
|||||||
N_("Std Dev:"),
|
N_("Std Dev:"),
|
||||||
N_("Median:"),
|
N_("Median:"),
|
||||||
N_("Pixels:"),
|
N_("Pixels:"),
|
||||||
N_("Intensity:"),
|
|
||||||
N_("Count:"),
|
N_("Count:"),
|
||||||
N_("Percentile:")
|
N_("Percentile:")
|
||||||
};
|
};
|
||||||
@ -399,16 +400,13 @@ histogram_tool_dialog_new (GimpToolInfo *tool_info)
|
|||||||
gtk_widget_show (htd->channel_menu);
|
gtk_widget_show (htd->channel_menu);
|
||||||
|
|
||||||
/* The histogram tool histogram */
|
/* The histogram tool histogram */
|
||||||
frame = gtk_frame_new (NULL);
|
htd->histogram_box =
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
GIMP_HISTOGRAM_BOX (gimp_histogram_box_new (_("Intensity Range:")));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), GTK_WIDGET (htd->histogram_box),
|
||||||
gtk_widget_show (frame);
|
FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (GTK_WIDGET (htd->histogram_box));
|
||||||
|
|
||||||
htd->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH, HISTOGRAM_HEIGHT);
|
g_signal_connect (G_OBJECT (htd->histogram_box->histogram), "range_changed",
|
||||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (htd->histogram));
|
|
||||||
gtk_widget_show (GTK_WIDGET (htd->histogram));
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (htd->histogram), "range_changed",
|
|
||||||
G_CALLBACK (histogram_tool_histogram_range),
|
G_CALLBACK (histogram_tool_histogram_range),
|
||||||
htd);
|
htd);
|
||||||
|
|
||||||
@ -420,23 +418,23 @@ histogram_tool_dialog_new (GimpToolInfo *tool_info)
|
|||||||
|
|
||||||
htd->gradient = gtk_preview_new (GTK_PREVIEW_COLOR);
|
htd->gradient = gtk_preview_new (GTK_PREVIEW_COLOR);
|
||||||
gtk_preview_size (GTK_PREVIEW (htd->gradient),
|
gtk_preview_size (GTK_PREVIEW (htd->gradient),
|
||||||
HISTOGRAM_WIDTH, GRADIENT_HEIGHT);
|
GIMP_HISTOGRAM_VIEW_WIDTH, GRADIENT_HEIGHT);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(htd->gradient));
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET(htd->gradient));
|
||||||
gtk_widget_show (htd->gradient);
|
gtk_widget_show (htd->gradient);
|
||||||
|
|
||||||
histogram_tool_gradient_draw (htd->gradient, GIMP_HISTOGRAM_VALUE);
|
histogram_tool_gradient_draw (htd->gradient, GIMP_HISTOGRAM_VALUE);
|
||||||
|
|
||||||
/* The table containing histogram information */
|
/* The table containing histogram information */
|
||||||
table = gtk_table_new (4, 4, TRUE);
|
table = gtk_table_new (3, 4, TRUE);
|
||||||
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
gtk_table_set_col_spacings (GTK_TABLE (table), 6);
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), table, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (table);
|
gtk_widget_show (table);
|
||||||
|
|
||||||
/* the labels for histogram information */
|
/* the labels for histogram information */
|
||||||
for (i = 0; i < 7; i++)
|
for (i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
y = (i % 4);
|
y = (i % 3);
|
||||||
x = (i / 4) * 2;
|
x = (i / 3) * 2;
|
||||||
|
|
||||||
label = gtk_label_new (gettext(histogram_info_names[i]));
|
label = gtk_label_new (gettext(histogram_info_names[i]));
|
||||||
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
gtk_misc_set_alignment (GTK_MISC (label), 1.0, 0.5);
|
||||||
@ -482,7 +480,7 @@ histogram_tool_channel_callback (GtkWidget *widget,
|
|||||||
|
|
||||||
gimp_menu_item_update (widget, &htd->channel);
|
gimp_menu_item_update (widget, &htd->channel);
|
||||||
|
|
||||||
gimp_histogram_view_channel (htd->histogram, htd->channel);
|
gimp_histogram_view_channel (htd->histogram_box->histogram, htd->channel);
|
||||||
histogram_tool_gradient_draw (htd->gradient, htd->channel);
|
histogram_tool_gradient_draw (htd->gradient, htd->channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -511,7 +509,7 @@ static void
|
|||||||
histogram_tool_gradient_draw (GtkWidget *gradient,
|
histogram_tool_gradient_draw (GtkWidget *gradient,
|
||||||
GimpHistogramChannel channel)
|
GimpHistogramChannel channel)
|
||||||
{
|
{
|
||||||
guchar buf[HISTOGRAM_WIDTH * 3];
|
guchar buf[GIMP_HISTOGRAM_VIEW_WIDTH * 3];
|
||||||
guchar r, g, b;
|
guchar r, g, b;
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
@ -532,7 +530,7 @@ histogram_tool_gradient_draw (GtkWidget *gradient,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < HISTOGRAM_WIDTH; i++)
|
for (i = 0; i < GIMP_HISTOGRAM_VIEW_WIDTH; i++)
|
||||||
{
|
{
|
||||||
buf[3 * i + 0] = i * r;
|
buf[3 * i + 0] = i * r;
|
||||||
buf[3 * i + 1] = i * g;
|
buf[3 * i + 1] = i * g;
|
||||||
@ -541,7 +539,7 @@ histogram_tool_gradient_draw (GtkWidget *gradient,
|
|||||||
|
|
||||||
for (i = 0; i < GRADIENT_HEIGHT; i++)
|
for (i = 0; i < GRADIENT_HEIGHT; i++)
|
||||||
gtk_preview_draw_row (GTK_PREVIEW (gradient),
|
gtk_preview_draw_row (GTK_PREVIEW (gradient),
|
||||||
buf, 0, i, HISTOGRAM_WIDTH);
|
buf, 0, i, GIMP_HISTOGRAM_VIEW_WIDTH);
|
||||||
|
|
||||||
gtk_widget_queue_draw (gradient);
|
gtk_widget_queue_draw (gradient);
|
||||||
}
|
}
|
||||||
|
@ -23,10 +23,6 @@
|
|||||||
#include "gimpimagemaptool.h"
|
#include "gimpimagemaptool.h"
|
||||||
|
|
||||||
|
|
||||||
#define HISTOGRAM_WIDTH 256
|
|
||||||
#define HISTOGRAM_HEIGHT 150
|
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_HISTOGRAM_TOOL (gimp_histogram_tool_get_type ())
|
#define GIMP_TYPE_HISTOGRAM_TOOL (gimp_histogram_tool_get_type ())
|
||||||
#define GIMP_HISTOGRAM_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_TOOL, GimpHistogramTool))
|
#define GIMP_HISTOGRAM_TOOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_TOOL, GimpHistogramTool))
|
||||||
#define GIMP_HISTOGRAM_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HISTOGRAM_TOOL, GimpHistogramToolClass))
|
#define GIMP_HISTOGRAM_TOOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HISTOGRAM_TOOL, GimpHistogramToolClass))
|
||||||
|
@ -67,12 +67,10 @@
|
|||||||
#define DRAW 0x200
|
#define DRAW 0x200
|
||||||
#define ALL 0xFFF
|
#define ALL 0xFFF
|
||||||
|
|
||||||
#define DA_WIDTH 256
|
#define DA_WIDTH GIMP_HISTOGRAM_VIEW_WIDTH
|
||||||
#define DA_HEIGHT 25
|
#define DA_HEIGHT 25
|
||||||
#define GRADIENT_HEIGHT 15
|
#define GRADIENT_HEIGHT 15
|
||||||
#define CONTROL_HEIGHT DA_HEIGHT - GRADIENT_HEIGHT
|
#define CONTROL_HEIGHT DA_HEIGHT - GRADIENT_HEIGHT
|
||||||
#define HISTOGRAM_WIDTH 256
|
|
||||||
#define HISTOGRAM_HEIGHT 150
|
|
||||||
|
|
||||||
#define LEVELS_DA_MASK GDK_EXPOSURE_MASK | \
|
#define LEVELS_DA_MASK GDK_EXPOSURE_MASK | \
|
||||||
GDK_ENTER_NOTIFY_MASK | \
|
GDK_ENTER_NOTIFY_MASK | \
|
||||||
@ -301,7 +299,7 @@ gimp_levels_tool_initialize (GimpTool *tool,
|
|||||||
|
|
||||||
gimp_drawable_calculate_histogram (drawable, l_tool->hist);
|
gimp_drawable_calculate_histogram (drawable, l_tool->hist);
|
||||||
gimp_histogram_view_update (l_tool->histogram, l_tool->hist);
|
gimp_histogram_view_update (l_tool->histogram, l_tool->hist);
|
||||||
gimp_histogram_view_range (l_tool->histogram, -1, -1);
|
gimp_histogram_view_set_range (l_tool->histogram, -1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -394,8 +392,8 @@ gimp_levels_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||||||
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox2), frame, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (frame);
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
l_tool->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH,
|
l_tool->histogram = gimp_histogram_view_new (GIMP_HISTOGRAM_VIEW_WIDTH,
|
||||||
HISTOGRAM_HEIGHT);
|
GIMP_HISTOGRAM_VIEW_HEIGHT);
|
||||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (l_tool->histogram));
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (l_tool->histogram));
|
||||||
|
|
||||||
/* ignore button_events, since we don't want the user to be able to set the range */
|
/* ignore button_events, since we don't want the user to be able to set the range */
|
||||||
|
@ -32,6 +32,7 @@
|
|||||||
#include "core/gimpimage.h"
|
#include "core/gimpimage.h"
|
||||||
#include "core/gimpimagemap.h"
|
#include "core/gimpimagemap.h"
|
||||||
|
|
||||||
|
#include "widgets/gimphistogrambox.h"
|
||||||
#include "widgets/gimphistogramview.h"
|
#include "widgets/gimphistogramview.h"
|
||||||
|
|
||||||
#include "display/gimpdisplay.h"
|
#include "display/gimpdisplay.h"
|
||||||
@ -42,9 +43,6 @@
|
|||||||
#include "libgimp/gimpintl.h"
|
#include "libgimp/gimpintl.h"
|
||||||
|
|
||||||
|
|
||||||
#define HISTOGRAM_WIDTH 256
|
|
||||||
#define HISTOGRAM_HEIGHT 150
|
|
||||||
|
|
||||||
#define LOW 0x1
|
#define LOW 0x1
|
||||||
#define HIGH 0x2
|
#define HIGH 0x2
|
||||||
#define HISTOGRAM 0x4
|
#define HISTOGRAM 0x4
|
||||||
@ -65,16 +63,10 @@ static void gimp_threshold_tool_map (GimpImageMapTool *image_map_tool);
|
|||||||
static void gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool);
|
static void gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool);
|
||||||
static void gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool);
|
static void gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool);
|
||||||
|
|
||||||
static void threshold_update (GimpThresholdTool *t_tool,
|
static void gimp_threshold_tool_histogram_range (GimpHistogramView *view,
|
||||||
gint update);
|
gint start,
|
||||||
static void threshold_low_threshold_adjustment_update (GtkAdjustment *adj,
|
gint end,
|
||||||
gpointer data);
|
GimpThresholdTool *t_tool);
|
||||||
static void threshold_high_threshold_adjustment_update (GtkAdjustment *adj,
|
|
||||||
gpointer data);
|
|
||||||
static void threshold_histogram_range (GimpHistogramView *,
|
|
||||||
gint ,
|
|
||||||
gint ,
|
|
||||||
gpointer );
|
|
||||||
|
|
||||||
|
|
||||||
static GimpImageMapToolClass *parent_class = NULL;
|
static GimpImageMapToolClass *parent_class = NULL;
|
||||||
@ -220,16 +212,17 @@ gimp_threshold_tool_initialize (GimpTool *tool,
|
|||||||
|
|
||||||
gimp_drawable_calculate_histogram (drawable, t_tool->hist);
|
gimp_drawable_calculate_histogram (drawable, t_tool->hist);
|
||||||
|
|
||||||
g_signal_handlers_block_by_func (G_OBJECT (t_tool->histogram),
|
g_signal_handlers_block_by_func (G_OBJECT (t_tool->histogram_box->histogram),
|
||||||
threshold_histogram_range,
|
gimp_threshold_tool_histogram_range,
|
||||||
t_tool);
|
t_tool);
|
||||||
gimp_histogram_view_update (t_tool->histogram, t_tool->hist);
|
gimp_histogram_view_update (t_tool->histogram_box->histogram, t_tool->hist);
|
||||||
g_signal_handlers_unblock_by_func (G_OBJECT (t_tool->histogram),
|
gimp_histogram_view_set_range (t_tool->histogram_box->histogram,
|
||||||
threshold_histogram_range,
|
t_tool->threshold->low_threshold,
|
||||||
|
t_tool->threshold->high_threshold);
|
||||||
|
g_signal_handlers_unblock_by_func (G_OBJECT (t_tool->histogram_box->histogram),
|
||||||
|
gimp_threshold_tool_histogram_range,
|
||||||
t_tool);
|
t_tool);
|
||||||
|
|
||||||
threshold_update (t_tool, ALL);
|
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,10 +249,7 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||||||
GimpThresholdTool *t_tool;
|
GimpThresholdTool *t_tool;
|
||||||
GtkWidget *hbox;
|
GtkWidget *hbox;
|
||||||
GtkWidget *vbox;
|
GtkWidget *vbox;
|
||||||
GtkWidget *spinbutton;
|
GtkWidget *histbox;
|
||||||
GtkWidget *label;
|
|
||||||
GtkWidget *frame;
|
|
||||||
GtkObject *data;
|
|
||||||
|
|
||||||
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
t_tool = GIMP_THRESHOLD_TOOL (image_map_tool);
|
||||||
|
|
||||||
@ -271,53 +261,14 @@ gimp_threshold_tool_dialog (GimpImageMapTool *image_map_tool)
|
|||||||
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (hbox), vbox, TRUE, FALSE, 0);
|
||||||
gtk_widget_show (vbox);
|
gtk_widget_show (vbox);
|
||||||
|
|
||||||
hbox = gtk_hbox_new (FALSE, 4);
|
histbox = gimp_histogram_box_new (_("Threshold Range:"));
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
gtk_box_pack_start (GTK_BOX (vbox), histbox, FALSE, FALSE, 0);
|
||||||
gtk_widget_show (hbox);
|
gtk_widget_show (histbox);
|
||||||
|
|
||||||
label = gtk_label_new (_("Threshold Range:"));
|
t_tool->histogram_box = GIMP_HISTOGRAM_BOX (histbox);
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (label);
|
|
||||||
|
|
||||||
/* low threshold spinbutton */
|
g_signal_connect (G_OBJECT (t_tool->histogram_box->histogram), "range_changed",
|
||||||
data = gtk_adjustment_new (t_tool->threshold->low_threshold,
|
G_CALLBACK (gimp_threshold_tool_histogram_range),
|
||||||
0.0, 255.0, 1.0, 10.0, 0.0);
|
|
||||||
t_tool->low_threshold_data = GTK_ADJUSTMENT (data);
|
|
||||||
|
|
||||||
spinbutton = gtk_spin_button_new (t_tool->low_threshold_data, 1.0, 0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (spinbutton);
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (t_tool->low_threshold_data), "value_changed",
|
|
||||||
G_CALLBACK (threshold_low_threshold_adjustment_update),
|
|
||||||
t_tool);
|
|
||||||
|
|
||||||
/* high threshold spinbutton */
|
|
||||||
data = gtk_adjustment_new (t_tool->threshold->high_threshold,
|
|
||||||
0.0, 255.0, 1.0, 10.0, 0.0);
|
|
||||||
t_tool->high_threshold_data = GTK_ADJUSTMENT (data);
|
|
||||||
|
|
||||||
spinbutton = gtk_spin_button_new (t_tool->high_threshold_data, 1.0, 0);
|
|
||||||
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (spinbutton);
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (t_tool->high_threshold_data), "value_changed",
|
|
||||||
G_CALLBACK (threshold_high_threshold_adjustment_update),
|
|
||||||
t_tool);
|
|
||||||
|
|
||||||
/* The threshold histogram */
|
|
||||||
frame = gtk_frame_new (NULL);
|
|
||||||
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
|
||||||
gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
|
|
||||||
gtk_widget_show (frame);
|
|
||||||
|
|
||||||
t_tool->histogram = gimp_histogram_view_new (HISTOGRAM_WIDTH,
|
|
||||||
HISTOGRAM_HEIGHT);
|
|
||||||
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (t_tool->histogram));
|
|
||||||
gtk_widget_show (GTK_WIDGET (t_tool->histogram));
|
|
||||||
|
|
||||||
g_signal_connect (G_OBJECT (t_tool->histogram), "range_changed",
|
|
||||||
G_CALLBACK (threshold_histogram_range),
|
|
||||||
t_tool);
|
t_tool);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -331,77 +282,23 @@ gimp_threshold_tool_reset (GimpImageMapTool *image_map_tool)
|
|||||||
t_tool->threshold->low_threshold = 127.0;
|
t_tool->threshold->low_threshold = 127.0;
|
||||||
t_tool->threshold->high_threshold = 255.0;
|
t_tool->threshold->high_threshold = 255.0;
|
||||||
|
|
||||||
threshold_update (t_tool, ALL);
|
gimp_histogram_view_set_range (t_tool->histogram_box->histogram,
|
||||||
|
t_tool->threshold->low_threshold,
|
||||||
|
t_tool->threshold->high_threshold);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
threshold_update (GimpThresholdTool *t_tool,
|
gimp_threshold_tool_histogram_range (GimpHistogramView *widget,
|
||||||
gint update)
|
gint start,
|
||||||
|
gint end,
|
||||||
|
GimpThresholdTool *t_tool)
|
||||||
{
|
{
|
||||||
if (update & LOW)
|
if (start != t_tool->threshold->low_threshold ||
|
||||||
gtk_adjustment_set_value (t_tool->low_threshold_data,
|
end != t_tool->threshold->high_threshold)
|
||||||
t_tool->threshold->low_threshold);
|
|
||||||
|
|
||||||
if (update & HIGH)
|
|
||||||
gtk_adjustment_set_value (t_tool->high_threshold_data,
|
|
||||||
t_tool->threshold->high_threshold);
|
|
||||||
|
|
||||||
if (update & HISTOGRAM)
|
|
||||||
gimp_histogram_view_range (t_tool->histogram,
|
|
||||||
t_tool->threshold->low_threshold,
|
|
||||||
t_tool->threshold->high_threshold);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
threshold_low_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GimpThresholdTool *t_tool;
|
|
||||||
|
|
||||||
t_tool = GIMP_THRESHOLD_TOOL (data);
|
|
||||||
|
|
||||||
if (t_tool->threshold->low_threshold != adjustment->value)
|
|
||||||
{
|
{
|
||||||
t_tool->threshold->low_threshold = adjustment->value;
|
t_tool->threshold->low_threshold = start;
|
||||||
|
t_tool->threshold->high_threshold = end;
|
||||||
threshold_update (t_tool, HISTOGRAM);
|
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
threshold_high_threshold_adjustment_update (GtkAdjustment *adjustment,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GimpThresholdTool *t_tool;
|
|
||||||
|
|
||||||
t_tool = GIMP_THRESHOLD_TOOL (data);
|
|
||||||
|
|
||||||
if (t_tool->threshold->high_threshold != adjustment->value)
|
|
||||||
{
|
|
||||||
t_tool->threshold->high_threshold = adjustment->value;
|
|
||||||
|
|
||||||
threshold_update (t_tool, HISTOGRAM);
|
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
threshold_histogram_range (GimpHistogramView *widget,
|
|
||||||
gint start,
|
|
||||||
gint end,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
GimpThresholdTool *t_tool;
|
|
||||||
|
|
||||||
t_tool = GIMP_THRESHOLD_TOOL (data);
|
|
||||||
|
|
||||||
t_tool->threshold->low_threshold = start;
|
|
||||||
t_tool->threshold->high_threshold = end;
|
|
||||||
|
|
||||||
threshold_update (t_tool, LOW | HIGH);
|
|
||||||
|
|
||||||
gimp_image_map_tool_preview (GIMP_IMAGE_MAP_TOOL (t_tool));
|
|
||||||
}
|
|
||||||
|
@ -36,15 +36,13 @@ typedef struct _GimpThresholdToolClass GimpThresholdToolClass;
|
|||||||
|
|
||||||
struct _GimpThresholdTool
|
struct _GimpThresholdTool
|
||||||
{
|
{
|
||||||
GimpImageMapTool parent_instance;
|
GimpImageMapTool parent_instance;
|
||||||
|
|
||||||
Threshold *threshold;
|
Threshold *threshold;
|
||||||
|
|
||||||
/* dialog */
|
/* dialog */
|
||||||
GimpHistogram *hist;
|
GimpHistogram *hist;
|
||||||
GimpHistogramView *histogram;
|
GimpHistogramBox *histogram_box;
|
||||||
GtkAdjustment *low_threshold_data;
|
|
||||||
GtkAdjustment *high_threshold_data;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _GimpThresholdToolClass
|
struct _GimpThresholdToolClass
|
||||||
|
@ -95,6 +95,8 @@ libappwidgets_a_sources = \
|
|||||||
gimpgradientpreview.h \
|
gimpgradientpreview.h \
|
||||||
gimphelp.c \
|
gimphelp.c \
|
||||||
gimphelp.h \
|
gimphelp.h \
|
||||||
|
gimphistogrambox.c \
|
||||||
|
gimphistogrambox.h \
|
||||||
gimphistogramview.c \
|
gimphistogramview.c \
|
||||||
gimphistogramview.h \
|
gimphistogramview.h \
|
||||||
gimpimagedock.c \
|
gimpimagedock.c \
|
||||||
|
200
app/widgets/gimphistogrambox.c
Normal file
200
app/widgets/gimphistogrambox.c
Normal file
@ -0,0 +1,200 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* 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 2 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
|
#include <gtk/gtk.h>
|
||||||
|
|
||||||
|
#include "libgimpwidgets/gimpwidgets.h"
|
||||||
|
|
||||||
|
#include "widgets-types.h"
|
||||||
|
|
||||||
|
#include "base/gimphistogram.h"
|
||||||
|
|
||||||
|
#include "gimphistogrambox.h"
|
||||||
|
#include "gimphistogramview.h"
|
||||||
|
|
||||||
|
#include "libgimp/gimpintl.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* local function prototypes */
|
||||||
|
|
||||||
|
static void gimp_histogram_box_class_init (GimpHistogramBoxClass *klass);
|
||||||
|
static void gimp_histogram_box_init (GimpHistogramBox *histogram_box);
|
||||||
|
|
||||||
|
static void gimp_histogram_box_low_adj_update (GtkAdjustment *adj,
|
||||||
|
GimpHistogramBox *box);
|
||||||
|
static void gimp_histogram_box_high_adj_update (GtkAdjustment *adj,
|
||||||
|
GimpHistogramBox *box);
|
||||||
|
static void gimp_histogram_box_histogram_range (GimpHistogramView *view,
|
||||||
|
gint start,
|
||||||
|
gint end,
|
||||||
|
GimpHistogramBox *box);
|
||||||
|
|
||||||
|
|
||||||
|
static GtkVBoxClass *parent_class = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
GType
|
||||||
|
gimp_histogram_box_get_type (void)
|
||||||
|
{
|
||||||
|
static GType box_type = 0;
|
||||||
|
|
||||||
|
if (! box_type)
|
||||||
|
{
|
||||||
|
static const GTypeInfo box_info =
|
||||||
|
{
|
||||||
|
sizeof (GimpHistogramBoxClass),
|
||||||
|
(GBaseInitFunc) NULL,
|
||||||
|
(GBaseFinalizeFunc) NULL,
|
||||||
|
(GClassInitFunc) gimp_histogram_box_class_init,
|
||||||
|
NULL, /* class_finalize */
|
||||||
|
NULL, /* class_data */
|
||||||
|
sizeof (GimpHistogramBox),
|
||||||
|
0, /* n_preallocs */
|
||||||
|
(GInstanceInitFunc) gimp_histogram_box_init,
|
||||||
|
};
|
||||||
|
|
||||||
|
box_type = g_type_register_static (GTK_TYPE_VBOX,
|
||||||
|
"GimpHistogramBox",
|
||||||
|
&box_info, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
return box_type;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_box_class_init (GimpHistogramBoxClass *klass)
|
||||||
|
{
|
||||||
|
parent_class = g_type_class_peek_parent (klass);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_box_init (GimpHistogramBox *box)
|
||||||
|
{
|
||||||
|
GtkWidget *hbox;
|
||||||
|
GtkWidget *spinbutton;
|
||||||
|
GtkObject *adjustment;
|
||||||
|
GtkWidget *frame;
|
||||||
|
|
||||||
|
gtk_box_set_spacing (GTK_BOX (box), 4);
|
||||||
|
|
||||||
|
hbox = gtk_hbox_new (FALSE, 4);
|
||||||
|
gtk_box_pack_start (GTK_BOX (box), hbox, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (hbox);
|
||||||
|
|
||||||
|
box->label = gtk_label_new (NULL);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), box->label, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (box->label);
|
||||||
|
|
||||||
|
/* low spinbutton */
|
||||||
|
spinbutton = gimp_spin_button_new (&adjustment,
|
||||||
|
0.0, 0.0, 255.0, 1.0, 16.0, 0.0,
|
||||||
|
1.0, 0);
|
||||||
|
box->low_adj = GTK_ADJUSTMENT (adjustment);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (spinbutton);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (adjustment), "value_changed",
|
||||||
|
G_CALLBACK (gimp_histogram_box_low_adj_update),
|
||||||
|
box);
|
||||||
|
|
||||||
|
/* high spinbutton */
|
||||||
|
spinbutton = gimp_spin_button_new (&adjustment,
|
||||||
|
255.0, 0.0, 255.0, 1.0, 16.0, 0.0,
|
||||||
|
1.0, 0);
|
||||||
|
box->high_adj = GTK_ADJUSTMENT (adjustment);
|
||||||
|
gtk_box_pack_start (GTK_BOX (hbox), spinbutton, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (spinbutton);
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (adjustment), "value_changed",
|
||||||
|
G_CALLBACK (gimp_histogram_box_high_adj_update),
|
||||||
|
box);
|
||||||
|
|
||||||
|
/* The histogram */
|
||||||
|
frame = gtk_frame_new (NULL);
|
||||||
|
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_IN);
|
||||||
|
gtk_box_pack_start (GTK_BOX (box), frame, FALSE, FALSE, 0);
|
||||||
|
gtk_widget_show (frame);
|
||||||
|
|
||||||
|
box->histogram = gimp_histogram_view_new (GIMP_HISTOGRAM_VIEW_WIDTH,
|
||||||
|
GIMP_HISTOGRAM_VIEW_HEIGHT);
|
||||||
|
gtk_container_add (GTK_CONTAINER (frame), GTK_WIDGET (box->histogram));
|
||||||
|
gtk_widget_show (GTK_WIDGET (box->histogram));
|
||||||
|
|
||||||
|
g_signal_connect (G_OBJECT (box->histogram), "range_changed",
|
||||||
|
G_CALLBACK (gimp_histogram_box_histogram_range),
|
||||||
|
box);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_box_low_adj_update (GtkAdjustment *adjustment,
|
||||||
|
GimpHistogramBox *box)
|
||||||
|
{
|
||||||
|
if ((gdouble) box->histogram->start != adjustment->value)
|
||||||
|
{
|
||||||
|
box->high_adj->lower = adjustment->value;
|
||||||
|
gtk_adjustment_changed (box->high_adj);
|
||||||
|
|
||||||
|
gimp_histogram_view_set_range (box->histogram,
|
||||||
|
(gint) adjustment->value,
|
||||||
|
box->histogram->end);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_box_high_adj_update (GtkAdjustment *adjustment,
|
||||||
|
GimpHistogramBox *box)
|
||||||
|
{
|
||||||
|
if ((gdouble) box->histogram->end != adjustment->value)
|
||||||
|
{
|
||||||
|
box->low_adj->upper = adjustment->value;
|
||||||
|
gtk_adjustment_changed (box->low_adj);
|
||||||
|
|
||||||
|
gimp_histogram_view_set_range (box->histogram,
|
||||||
|
box->histogram->start,
|
||||||
|
(gint) adjustment->value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gimp_histogram_box_histogram_range (GimpHistogramView *widget,
|
||||||
|
gint start,
|
||||||
|
gint end,
|
||||||
|
GimpHistogramBox *box)
|
||||||
|
{
|
||||||
|
box->high_adj->lower = start;
|
||||||
|
box->low_adj->upper = end;
|
||||||
|
gtk_adjustment_changed (box->high_adj);
|
||||||
|
gtk_adjustment_changed (box->low_adj);
|
||||||
|
|
||||||
|
gtk_adjustment_set_value (box->low_adj, start);
|
||||||
|
gtk_adjustment_set_value (box->high_adj, end);
|
||||||
|
}
|
||||||
|
|
||||||
|
GtkWidget *
|
||||||
|
gimp_histogram_box_new (const gchar *label)
|
||||||
|
{
|
||||||
|
GimpHistogramBox *box;
|
||||||
|
|
||||||
|
box = g_object_new (GIMP_TYPE_HISTOGRAM_BOX, NULL);
|
||||||
|
|
||||||
|
gtk_label_set_text (GTK_LABEL (box->label), label);
|
||||||
|
|
||||||
|
return GTK_WIDGET (box);
|
||||||
|
}
|
54
app/widgets/gimphistogrambox.h
Normal file
54
app/widgets/gimphistogrambox.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/* The GIMP -- an image manipulation program
|
||||||
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||||
|
*
|
||||||
|
* 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 2 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, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIMP_HISTOGRAM_BOX_H__
|
||||||
|
#define __GIMP_HISTOGRAM_BOX_H__
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_TYPE_HISTOGRAM_BOX (gimp_histogram_box_get_type ())
|
||||||
|
#define GIMP_HISTOGRAM_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_BOX, GimpHistogramBox))
|
||||||
|
#define GIMP_HISTOGRAM_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HISTOGRAM_BOX, GimpHistogramBoxClass))
|
||||||
|
#define GIMP_IS_HISTOGRAM_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GIMP_TYPE_HISTOGRAM_BOX))
|
||||||
|
#define GIMP_IS_HISTOGRAM_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GIMP_TYPE_HISTOGRAM_BOX))
|
||||||
|
#define GIMP_HISTOGRAM_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GIMP_TYPE_HISTOGRAM_BOX, GimpHistogramBoxClass))
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct _GimpHistogramBoxClass GimpHistogramBoxClass;
|
||||||
|
|
||||||
|
struct _GimpHistogramBox
|
||||||
|
{
|
||||||
|
GtkVBox parent_instance;
|
||||||
|
|
||||||
|
GtkWidget *label;
|
||||||
|
GtkAdjustment *low_adj;
|
||||||
|
GtkAdjustment *high_adj;
|
||||||
|
GimpHistogramView *histogram;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _GimpHistogramBoxClass
|
||||||
|
{
|
||||||
|
GtkVBoxClass parent_class;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
GType gimp_histogram_box_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GtkWidget * gimp_histogram_box_new (const gchar *label);
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* __GIMP_HISTOGRAM_BOX_H__ */
|
@ -168,7 +168,7 @@ gimp_histogram_view_draw (GimpHistogramView *view,
|
|||||||
if ((update & RANGE) && view->start >= 0)
|
if ((update & RANGE) && view->start >= 0)
|
||||||
{
|
{
|
||||||
x1 = (width * MIN (view->start, view->end)) / 256 + 1;
|
x1 = (width * MIN (view->start, view->end)) / 256 + 1;
|
||||||
x2 = (width * MAX (view->start, view->end)) / 256 + 1;
|
x2 = (width * MAX (view->start, view->end)) / 256 + 1;
|
||||||
|
|
||||||
gdk_gc_set_function (widget->style->black_gc, GDK_INVERT);
|
gdk_gc_set_function (widget->style->black_gc, GDK_INVERT);
|
||||||
gdk_draw_rectangle (widget->window,
|
gdk_draw_rectangle (widget->window,
|
||||||
@ -210,7 +210,7 @@ gimp_histogram_view_events (GimpHistogramView *view,
|
|||||||
gimp_histogram_view_draw (view, RANGE);
|
gimp_histogram_view_draw (view, RANGE);
|
||||||
|
|
||||||
view->start = CLAMP ((((bevent->x - 1) * 256) / width), 0, 255);
|
view->start = CLAMP ((((bevent->x - 1) * 256) / width), 0, 255);
|
||||||
view->end = view->start;
|
view->end = view->start;
|
||||||
|
|
||||||
gimp_histogram_view_draw (view, RANGE);
|
gimp_histogram_view_draw (view, RANGE);
|
||||||
break;
|
break;
|
||||||
@ -220,10 +220,19 @@ gimp_histogram_view_events (GimpHistogramView *view,
|
|||||||
|
|
||||||
gdk_pointer_ungrab (bevent->time);
|
gdk_pointer_ungrab (bevent->time);
|
||||||
|
|
||||||
|
{
|
||||||
|
gint start, end;
|
||||||
|
|
||||||
|
start = view->start;
|
||||||
|
end = view->end;
|
||||||
|
|
||||||
|
view->start = MIN (start, end);
|
||||||
|
view->end = MAX (start, end);
|
||||||
|
}
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (view),
|
g_signal_emit (G_OBJECT (view),
|
||||||
histogram_view_signals[RANGE_CHANGED], 0,
|
histogram_view_signals[RANGE_CHANGED], 0,
|
||||||
MIN (view->start, view->end),
|
view->start, view->end);
|
||||||
MAX (view->start, view->end));
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GDK_MOTION_NOTIFY:
|
case GDK_MOTION_NOTIFY:
|
||||||
@ -266,6 +275,8 @@ void
|
|||||||
gimp_histogram_view_update (GimpHistogramView *view,
|
gimp_histogram_view_update (GimpHistogramView *view,
|
||||||
GimpHistogram *histogram)
|
GimpHistogram *histogram)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
|
||||||
|
|
||||||
view->histogram = histogram;
|
view->histogram = histogram;
|
||||||
|
|
||||||
if (! histogram)
|
if (! histogram)
|
||||||
@ -278,39 +289,45 @@ gimp_histogram_view_update (GimpHistogramView *view,
|
|||||||
|
|
||||||
g_signal_emit (G_OBJECT (view),
|
g_signal_emit (G_OBJECT (view),
|
||||||
histogram_view_signals[RANGE_CHANGED], 0,
|
histogram_view_signals[RANGE_CHANGED], 0,
|
||||||
MIN (view->start, view->end),
|
view->start, view->end);
|
||||||
MAX (view->start, view->end));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_histogram_view_range (GimpHistogramView *view,
|
gimp_histogram_view_set_range (GimpHistogramView *view,
|
||||||
gint start,
|
gint start,
|
||||||
gint end)
|
gint end)
|
||||||
{
|
{
|
||||||
gimp_histogram_view_draw (view, RANGE);
|
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
|
||||||
|
|
||||||
view->start = start;
|
|
||||||
view->end = end;
|
|
||||||
|
|
||||||
gimp_histogram_view_draw (view, RANGE);
|
gimp_histogram_view_draw (view, RANGE);
|
||||||
|
|
||||||
|
view->start = MIN (start, end);
|
||||||
|
view->end = MAX (start, end);
|
||||||
|
|
||||||
|
gimp_histogram_view_draw (view, RANGE);
|
||||||
|
|
||||||
|
g_signal_emit (G_OBJECT (view),
|
||||||
|
histogram_view_signals[RANGE_CHANGED], 0,
|
||||||
|
view->start, view->end);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_histogram_view_channel (GimpHistogramView *view,
|
gimp_histogram_view_channel (GimpHistogramView *view,
|
||||||
gint channel)
|
gint channel)
|
||||||
{
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_HISTOGRAM_VIEW (view));
|
||||||
|
|
||||||
view->channel = channel;
|
view->channel = channel;
|
||||||
|
|
||||||
gimp_histogram_view_draw (view, ALL);
|
gimp_histogram_view_draw (view, ALL);
|
||||||
|
|
||||||
g_signal_emit (G_OBJECT (view),
|
g_signal_emit (G_OBJECT (view),
|
||||||
histogram_view_signals[RANGE_CHANGED], 0,
|
histogram_view_signals[RANGE_CHANGED], 0,
|
||||||
MIN (view->start, view->end),
|
view->start, view->end);
|
||||||
MAX (view->start, view->end));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GimpHistogram *
|
GimpHistogram *
|
||||||
gimp_histogram_view_histogram (GimpHistogramView *view)
|
gimp_histogram_view_get_histogram (GimpHistogramView *view)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (GIMP_IS_HISTOGRAM_VIEW (view), NULL);
|
g_return_val_if_fail (GIMP_IS_HISTOGRAM_VIEW (view), NULL);
|
||||||
|
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
#include <gtk/gtkdrawingarea.h>
|
#include <gtk/gtkdrawingarea.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define GIMP_HISTOGRAM_VIEW_WIDTH 256
|
||||||
|
#define GIMP_HISTOGRAM_VIEW_HEIGHT 150
|
||||||
|
|
||||||
|
|
||||||
#define GIMP_TYPE_HISTOGRAM_VIEW (gimp_histogram_view_get_type ())
|
#define GIMP_TYPE_HISTOGRAM_VIEW (gimp_histogram_view_get_type ())
|
||||||
#define GIMP_HISTOGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_VIEW, GimpHistogramView))
|
#define GIMP_HISTOGRAM_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GIMP_TYPE_HISTOGRAM_VIEW, GimpHistogramView))
|
||||||
#define GIMP_HISTOGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HISTOGRAM_VIEW, GimpHistogramViewClass))
|
#define GIMP_HISTOGRAM_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GIMP_TYPE_HISTOGRAM_VIEW, GimpHistogramViewClass))
|
||||||
@ -53,20 +57,18 @@ struct _GimpHistogramViewClass
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/* Histogram functions */
|
GType gimp_histogram_view_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
GType gimp_histogram_view_get_type (void) G_GNUC_CONST;
|
GimpHistogramView * gimp_histogram_view_new (gint width,
|
||||||
|
gint height);
|
||||||
GimpHistogramView * gimp_histogram_view_new (gint width,
|
void gimp_histogram_view_update (GimpHistogramView *view,
|
||||||
gint height);
|
GimpHistogram *histogram);
|
||||||
void gimp_histogram_view_update (GimpHistogramView *view,
|
void gimp_histogram_view_set_range (GimpHistogramView *view,
|
||||||
GimpHistogram *histogram);
|
gint start,
|
||||||
void gimp_histogram_view_range (GimpHistogramView *view,
|
gint end);
|
||||||
gint start,
|
void gimp_histogram_view_channel (GimpHistogramView *view,
|
||||||
gint end);
|
gint channel);
|
||||||
void gimp_histogram_view_channel (GimpHistogramView *view,
|
GimpHistogram * gimp_histogram_view_get_histogram (GimpHistogramView *view);
|
||||||
gint channel);
|
|
||||||
GimpHistogram * gimp_histogram_view_histogram (GimpHistogramView *view);
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* __GIMP_HISTOGRAM_VIEW_H__ */
|
#endif /* __GIMP_HISTOGRAM_VIEW_H__ */
|
||||||
|
@ -98,6 +98,7 @@ typedef struct _GimpFontSelection GimpFontSelection;
|
|||||||
typedef struct _GimpFontSelectionDialog GimpFontSelectionDialog;
|
typedef struct _GimpFontSelectionDialog GimpFontSelectionDialog;
|
||||||
|
|
||||||
typedef struct _GimpHistogramView GimpHistogramView;
|
typedef struct _GimpHistogramView GimpHistogramView;
|
||||||
|
typedef struct _GimpHistogramBox GimpHistogramBox;
|
||||||
|
|
||||||
|
|
||||||
/* function types */
|
/* function types */
|
||||||
|
Reference in New Issue
Block a user