Commit 2ad8a17e authored by Sven Neumann's avatar Sven Neumann
Browse files

app/gdisplay.c app/gimage_cmds.c fixed typos

 * app/gdisplay.c
 * app/gimage_cmds.c
 * tools/pdbgen/pdb/gimage.pdb: fixed typos

 * app/gimphistogram.c: indentation

 * app/histogramwidget.c: grab the pointer in the histogramwidget,
   so a button_release outside the widget is noticed correctly

 * app/levels.c: instead of undoing the user action, simply don't
   allow the user to set the range in the histogram_widget


--Sven
parent c4a22120
Sun Jan 9 14:48:21 CET 2000 Sven Neumann <sven@gimp.org>
* app/gdisplay.c
* app/gimage_cmds.c
* tools/pdbgen/pdb/gimage.pdb: fixed typos
* app/gimphistogram.c: indentation
* app/histogramwidget.c: grab the pointer in the histogramwidget,
so a button_release outside the widget is noticed correctly
* app/levels.c: instead of undoing the user action, simply don't
allow the user to set the range in the histogram_widget
2000-01-09 Shirasaki Yasuhiro <yasuhiro@gnome.gr.jp>
 
* plug-ins/common/tga.c
......
......@@ -38,10 +38,10 @@
GimpHistogram *
gimp_histogram_new()
gimp_histogram_new (void)
{
GimpHistogram *histogram;
histogram = g_new(GimpHistogram, 1);
histogram = g_new (GimpHistogram, 1);
histogram->values = NULL;
histogram->nchannels = 0;
return histogram;
......@@ -54,15 +54,16 @@ gimp_histogram_free (GimpHistogram *histogram)
if (histogram->values)
{
for (i = 0; i < histogram->nchannels; i++)
g_free(histogram->values[i]);
g_free(histogram->values);
g_free (histogram->values[i]);
g_free (histogram->values);
}
g_free(histogram);
g_free (histogram);
}
void
gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
PixelRegion *region, PixelRegion *mask)
gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
PixelRegion *region,
PixelRegion *mask)
{
const unsigned char *src, *msrc;
const unsigned char *m, *s;
......@@ -71,14 +72,14 @@ gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
#ifdef ENABLE_MP
int slot = 0;
/* find an unused temporary slot to put our results in and lock it */
pthread_mutex_lock(&histogram->mutex);
pthread_mutex_lock (&histogram->mutex);
{
while (histogram->tmp_slots[slot])
slot++;
values = histogram->tmp_values[slot];
histogram->tmp_slots[slot] = 1;
}
pthread_mutex_unlock(&histogram->mutex);
pthread_mutex_unlock (&histogram->mutex);
#else /* !ENABLE_MP */
values = histogram->values;
#endif
......@@ -206,13 +207,15 @@ gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
#ifdef ENABLE_MP
/* unlock this slot */
/* we shouldn't have to use mutex locks here */
pthread_mutex_lock(&histogram->mutex);
pthread_mutex_lock (&histogram->mutex);
histogram->tmp_slots[slot] = 0;
pthread_mutex_unlock(&histogram->mutex);
pthread_mutex_unlock (&histogram->mutex);
#endif
}
static void gimp_histogram_alloc(GimpHistogram *histogram, int bytes)
static void
gimp_histogram_alloc (GimpHistogram *histogram,
int bytes)
{
int i;
if (bytes + 1 != histogram->nchannels)
......@@ -220,38 +223,39 @@ static void gimp_histogram_alloc(GimpHistogram *histogram, int bytes)
if (histogram->values)
{
for (i = 0; i < histogram->nchannels; i++)
g_free(histogram->values[i]);
g_free(histogram->values);
g_free (histogram->values[i]);
g_free (histogram->values);
}
histogram->nchannels = bytes + 1;
histogram->values = g_new(double *, histogram->nchannels);
histogram->values = g_new (double *, histogram->nchannels);
for (i = 0; i < histogram->nchannels; i++)
histogram->values[i] = g_new(double, 256);
histogram->values[i] = g_new (double, 256);
}
}
void
gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
PixelRegion *mask)
gimp_histogram_calculate (GimpHistogram *histogram,
PixelRegion *region,
PixelRegion *mask)
{
int i, j;
#ifdef ENABLE_MP
int k;
#endif
gimp_histogram_alloc(histogram, region->bytes);
gimp_histogram_alloc (histogram, region->bytes);
#ifdef ENABLE_MP
pthread_mutex_init(&histogram->mutex, NULL);
histogram->tmp_slots = g_new(char, num_processors);
histogram->tmp_values = g_new(double **, num_processors);
pthread_mutex_init (&histogram->mutex, NULL);
histogram->tmp_slots = g_new (char, num_processors);
histogram->tmp_values = g_new (double **, num_processors);
for (i = 0; i < num_processors; i++)
{
histogram->tmp_values[i] = g_new(double *, histogram->nchannels);
histogram->tmp_values[i] = g_new (double *, histogram->nchannels);
histogram->tmp_slots[i] = 0;
for (j = 0; j < histogram->nchannels; j++)
{
histogram->tmp_values[i][j] = g_new(double, 256);
histogram->tmp_values[i][j] = g_new (double, 256);
for (k = 0; k < 256; k++)
histogram->tmp_values[i][j][k] = 0.0;
}
......@@ -262,8 +266,8 @@ gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
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);
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 */
......@@ -275,17 +279,17 @@ gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
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[i]);
}
g_free(histogram->tmp_values);
g_free(histogram->tmp_slots);
g_free (histogram->tmp_values);
g_free (histogram->tmp_slots);
#endif
}
void
gimp_histogram_calculate_drawable(GimpHistogram *histogram,
GimpDrawable *drawable)
gimp_histogram_calculate_drawable (GimpHistogram *histogram,
GimpDrawable *drawable)
{
PixelRegion region;
PixelRegion mask;
......@@ -314,7 +318,8 @@ gimp_histogram_calculate_drawable(GimpHistogram *histogram,
}
double
gimp_histogram_get_maximum (GimpHistogram *histogram, int channel)
gimp_histogram_get_maximum (GimpHistogram *histogram,
int channel)
{
double max = 0.0;
int x;
......@@ -325,7 +330,9 @@ gimp_histogram_get_maximum (GimpHistogram *histogram, int channel)
}
double
gimp_histogram_get_value (GimpHistogram *histogram, int channel, int bin)
gimp_histogram_get_value (GimpHistogram *histogram,
int channel,
int bin)
{
if (channel < histogram->nchannels && bin >= 0 && bin < 256)
return histogram->values[channel][bin];
......@@ -333,12 +340,14 @@ gimp_histogram_get_value (GimpHistogram *histogram, int channel, int bin)
}
double
gimp_histogram_get_channel (GimpHistogram *histogram, int channel, int bin)
gimp_histogram_get_channel (GimpHistogram *histogram,
int channel,
int bin)
{
if (histogram->nchannels > 3)
return gimp_histogram_get_value(histogram, channel + 1, bin);
return gimp_histogram_get_value (histogram, channel + 1, bin);
else
return gimp_histogram_get_value(histogram, channel , bin);
return gimp_histogram_get_value (histogram, channel , bin);
}
int
......@@ -348,7 +357,9 @@ gimp_histogram_nchannels (GimpHistogram *histogram)
}
double
gimp_histogram_get_count (GimpHistogram *histogram, int start, int end)
gimp_histogram_get_count (GimpHistogram *histogram,
int start,
int end)
{
int i;
double count = 0.0;
......@@ -358,27 +369,32 @@ gimp_histogram_get_count (GimpHistogram *histogram, int start, int end)
}
double
gimp_histogram_get_mean (GimpHistogram *histogram, int channel,
int start, int end)
gimp_histogram_get_mean (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double mean = 0.0;
double count;
for (i = start; i <= end; i++)
mean += i * histogram->values[channel][i];
count = gimp_histogram_get_count(histogram, start, end);
count = gimp_histogram_get_count (histogram, start, end);
if (count > 0.0)
return mean / count;
return mean;
}
int
gimp_histogram_get_median (GimpHistogram *histogram, int channel, int start, int end)
gimp_histogram_get_median (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double sum = 0.0;
double count;
count = gimp_histogram_get_count(histogram, start, end);
count = gimp_histogram_get_count (histogram, start, end);
for (i = start; i <= end; i++)
{
sum += i * histogram->values[channel][i];
......@@ -389,8 +405,10 @@ gimp_histogram_get_median (GimpHistogram *histogram, int channel, int start, int
}
double
gimp_histogram_get_std_dev (GimpHistogram *histogram, int channel,
int start, int end)
gimp_histogram_get_std_dev (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double dev = 0.0;
......@@ -401,7 +419,7 @@ gimp_histogram_get_std_dev (GimpHistogram *histogram, int channel,
if (count == 0.0)
count = 1.0;
for (i = start; i <= end; i++)
dev += gimp_histogram_get_value(histogram, channel, i) *
dev += gimp_histogram_get_value (histogram, channel, i) *
(i - mean) * (i - mean);
return sqrt (dev / count);
}
......@@ -2146,7 +2146,7 @@ GDisplay *
gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{
/* Give a gdisp check that it is still valid and points to the require
/* Give a gdisp check that it is still valid and points to the required
* GimpImage. If not return the first gDisplay that does point to the
* gimage. If none found return NULL;
*/
......
......@@ -2146,7 +2146,7 @@ GDisplay *
gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{
/* Give a gdisp check that it is still valid and points to the require
/* Give a gdisp check that it is still valid and points to the required
* GimpImage. If not return the first gDisplay that does point to the
* gimage. If none found return NULL;
*/
......
......@@ -2146,7 +2146,7 @@ GDisplay *
gdisplays_check_valid (GDisplay *gtest,
GimpImage *gimage)
{
/* Give a gdisp check that it is still valid and points to the require
/* Give a gdisp check that it is still valid and points to the required
* GimpImage. If not return the first gDisplay that does point to the
* gimage. If none found return NULL;
*/
......
......@@ -2222,7 +2222,7 @@ static ProcRecord image_clean_all_proc =
{
"gimp_image_clean_all",
"Set the image dirty count to 0.",
"This procedure sets the specified image's dirty count to 0, allowing operations to occur without having a 'dirtied' image. This is especially useful for cre ating and loading images which should not initially be considered dirty, even though layers must be created, filled, and installed in the image.",
"This procedure sets the specified image's dirty count to 0, allowing operations to occur without having a 'dirtied' image. This is especially useful for creating and loading images which should not initially be considered dirty, even though layers must be created, filled, and installed in the image.",
"Spencer Kimball & Peter Mattis",
"Spencer Kimball & Peter Mattis",
"1995-1996",
......
......@@ -38,10 +38,10 @@
GimpHistogram *
gimp_histogram_new()
gimp_histogram_new (void)
{
GimpHistogram *histogram;
histogram = g_new(GimpHistogram, 1);
histogram = g_new (GimpHistogram, 1);
histogram->values = NULL;
histogram->nchannels = 0;
return histogram;
......@@ -54,15 +54,16 @@ gimp_histogram_free (GimpHistogram *histogram)
if (histogram->values)
{
for (i = 0; i < histogram->nchannels; i++)
g_free(histogram->values[i]);
g_free(histogram->values);
g_free (histogram->values[i]);
g_free (histogram->values);
}
g_free(histogram);
g_free (histogram);
}
void
gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
PixelRegion *region, PixelRegion *mask)
gimp_histogram_calculate_sub_region (GimpHistogram *histogram,
PixelRegion *region,
PixelRegion *mask)
{
const unsigned char *src, *msrc;
const unsigned char *m, *s;
......@@ -71,14 +72,14 @@ gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
#ifdef ENABLE_MP
int slot = 0;
/* find an unused temporary slot to put our results in and lock it */
pthread_mutex_lock(&histogram->mutex);
pthread_mutex_lock (&histogram->mutex);
{
while (histogram->tmp_slots[slot])
slot++;
values = histogram->tmp_values[slot];
histogram->tmp_slots[slot] = 1;
}
pthread_mutex_unlock(&histogram->mutex);
pthread_mutex_unlock (&histogram->mutex);
#else /* !ENABLE_MP */
values = histogram->values;
#endif
......@@ -206,13 +207,15 @@ gimp_histogram_calculate_sub_region(GimpHistogram *histogram,
#ifdef ENABLE_MP
/* unlock this slot */
/* we shouldn't have to use mutex locks here */
pthread_mutex_lock(&histogram->mutex);
pthread_mutex_lock (&histogram->mutex);
histogram->tmp_slots[slot] = 0;
pthread_mutex_unlock(&histogram->mutex);
pthread_mutex_unlock (&histogram->mutex);
#endif
}
static void gimp_histogram_alloc(GimpHistogram *histogram, int bytes)
static void
gimp_histogram_alloc (GimpHistogram *histogram,
int bytes)
{
int i;
if (bytes + 1 != histogram->nchannels)
......@@ -220,38 +223,39 @@ static void gimp_histogram_alloc(GimpHistogram *histogram, int bytes)
if (histogram->values)
{
for (i = 0; i < histogram->nchannels; i++)
g_free(histogram->values[i]);
g_free(histogram->values);
g_free (histogram->values[i]);
g_free (histogram->values);
}
histogram->nchannels = bytes + 1;
histogram->values = g_new(double *, histogram->nchannels);
histogram->values = g_new (double *, histogram->nchannels);
for (i = 0; i < histogram->nchannels; i++)
histogram->values[i] = g_new(double, 256);
histogram->values[i] = g_new (double, 256);
}
}
void
gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
PixelRegion *mask)
gimp_histogram_calculate (GimpHistogram *histogram,
PixelRegion *region,
PixelRegion *mask)
{
int i, j;
#ifdef ENABLE_MP
int k;
#endif
gimp_histogram_alloc(histogram, region->bytes);
gimp_histogram_alloc (histogram, region->bytes);
#ifdef ENABLE_MP
pthread_mutex_init(&histogram->mutex, NULL);
histogram->tmp_slots = g_new(char, num_processors);
histogram->tmp_values = g_new(double **, num_processors);
pthread_mutex_init (&histogram->mutex, NULL);
histogram->tmp_slots = g_new (char, num_processors);
histogram->tmp_values = g_new (double **, num_processors);
for (i = 0; i < num_processors; i++)
{
histogram->tmp_values[i] = g_new(double *, histogram->nchannels);
histogram->tmp_values[i] = g_new (double *, histogram->nchannels);
histogram->tmp_slots[i] = 0;
for (j = 0; j < histogram->nchannels; j++)
{
histogram->tmp_values[i][j] = g_new(double, 256);
histogram->tmp_values[i][j] = g_new (double, 256);
for (k = 0; k < 256; k++)
histogram->tmp_values[i][j][k] = 0.0;
}
......@@ -262,8 +266,8 @@ gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
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);
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 */
......@@ -275,17 +279,17 @@ gimp_histogram_calculate (GimpHistogram *histogram, PixelRegion *region,
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[i]);
}
g_free(histogram->tmp_values);
g_free(histogram->tmp_slots);
g_free (histogram->tmp_values);
g_free (histogram->tmp_slots);
#endif
}
void
gimp_histogram_calculate_drawable(GimpHistogram *histogram,
GimpDrawable *drawable)
gimp_histogram_calculate_drawable (GimpHistogram *histogram,
GimpDrawable *drawable)
{
PixelRegion region;
PixelRegion mask;
......@@ -314,7 +318,8 @@ gimp_histogram_calculate_drawable(GimpHistogram *histogram,
}
double
gimp_histogram_get_maximum (GimpHistogram *histogram, int channel)
gimp_histogram_get_maximum (GimpHistogram *histogram,
int channel)
{
double max = 0.0;
int x;
......@@ -325,7 +330,9 @@ gimp_histogram_get_maximum (GimpHistogram *histogram, int channel)
}
double
gimp_histogram_get_value (GimpHistogram *histogram, int channel, int bin)
gimp_histogram_get_value (GimpHistogram *histogram,
int channel,
int bin)
{
if (channel < histogram->nchannels && bin >= 0 && bin < 256)
return histogram->values[channel][bin];
......@@ -333,12 +340,14 @@ gimp_histogram_get_value (GimpHistogram *histogram, int channel, int bin)
}
double
gimp_histogram_get_channel (GimpHistogram *histogram, int channel, int bin)
gimp_histogram_get_channel (GimpHistogram *histogram,
int channel,
int bin)
{
if (histogram->nchannels > 3)
return gimp_histogram_get_value(histogram, channel + 1, bin);
return gimp_histogram_get_value (histogram, channel + 1, bin);
else
return gimp_histogram_get_value(histogram, channel , bin);
return gimp_histogram_get_value (histogram, channel , bin);
}
int
......@@ -348,7 +357,9 @@ gimp_histogram_nchannels (GimpHistogram *histogram)
}
double
gimp_histogram_get_count (GimpHistogram *histogram, int start, int end)
gimp_histogram_get_count (GimpHistogram *histogram,
int start,
int end)
{
int i;
double count = 0.0;
......@@ -358,27 +369,32 @@ gimp_histogram_get_count (GimpHistogram *histogram, int start, int end)
}
double
gimp_histogram_get_mean (GimpHistogram *histogram, int channel,
int start, int end)
gimp_histogram_get_mean (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double mean = 0.0;
double count;
for (i = start; i <= end; i++)
mean += i * histogram->values[channel][i];
count = gimp_histogram_get_count(histogram, start, end);
count = gimp_histogram_get_count (histogram, start, end);
if (count > 0.0)
return mean / count;
return mean;
}
int
gimp_histogram_get_median (GimpHistogram *histogram, int channel, int start, int end)
gimp_histogram_get_median (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double sum = 0.0;
double count;
count = gimp_histogram_get_count(histogram, start, end);
count = gimp_histogram_get_count (histogram, start, end);
for (i = start; i <= end; i++)
{
sum += i * histogram->values[channel][i];
......@@ -389,8 +405,10 @@ gimp_histogram_get_median (GimpHistogram *histogram, int channel, int start, int
}
double
gimp_histogram_get_std_dev (GimpHistogram *histogram, int channel,
int start, int end)
gimp_histogram_get_std_dev (GimpHistogram *histogram,
int channel,
int start,
int end)
{
int i;
double dev = 0.0;
......@@ -401,7 +419,7 @@ gimp_histogram_get_std_dev (GimpHistogram *histogram, int channel,
if (count == 0.0)
count = 1.0;
for (i = start; i <= end; i++)
dev += gimp_histogram_get_value(histogram, channel, i) *
dev += gimp_histogram_get_value (histogram, channel, i) *
(i - mean) * (i - mean);
return sqrt (dev / count);
}
......@@ -58,7 +58,7 @@ static void histogram_widget_init (HistogramWidget *histogram);
/* Function definitions */
guint
histogram_widget_get_type()
histogram_widget_get_type (void)
{
static guint type = 0;
if (!type)
......@@ -96,20 +96,21 @@ histogram_widget_class_init (HistogramWidgetClass *klass)
GTK_TYPE_INT,
GTK_TYPE_INT);
gtk_object_class_add_signals(GTK_OBJECT_CLASS(klass),
histogram_widget_signals, LAST_SIGNAL);
gtk_object_class_add_signals (GTK_OBJECT_CLASS(klass),
histogram_widget_signals, LAST_SIGNAL);
}
static void histogram_widget_init(HistogramWidget *histogram)
static void
histogram_widget_init (HistogramWidget *histogram)
{
histogram->histogram = NULL;
}
static void
histogram_widget_draw (HistogramWidget *histogram,
int update)
int update)
{
double max;
double v;
......@@ -168,7 +169,7 @@ histogram_widget_draw (HistogramWidget *histogram,
static gint
histogram_widget_events (HistogramWidget *histogram,
GdkEvent *event)
GdkEvent *event)
{
GdkEventButton *bevent;