Commit 0196e83f authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

app/gimphistogram.[ch] removed.

2001-05-23  Michael Natterer  <mitch@gimp.org>

	* app/gimphistogram.[ch]
	* app/lut_funcs.[ch]: removed.

	* app/base/gimphistogram.[ch]
	* app/base/lut-funcs.[ch]
	* app/core/gimpdrawable-histogram.[ch]: added, cleanup.

	* app/Makefile.am
	* app/appenums.h
	* app/apptypes.h
	* app/base/Makefile.am
	* app/base/base-types.h
	* app/core/Makefile.am
	* app/core/gimpchannel.c
	* app/core/gimpdrawable-equalize.c
	* app/core/gimpdrawable-invert.c
	* app/pdb/color_cmds.c
	* app/widgets/gimphistogramview.c
	* tools/pdbgen/Makefile.am
	* tools/pdbgen/enums.pl
	* tools/pdbgen/pdb/color.pdb: changed accordingly.
parent 884f6a8b
2001-05-23 Michael Natterer <mitch@gimp.org>
* app/gimphistogram.[ch]
* app/lut_funcs.[ch]: removed.
* app/base/gimphistogram.[ch]
* app/base/lut-funcs.[ch]
* app/core/gimpdrawable-histogram.[ch]: added, cleanup.
* app/Makefile.am
* app/appenums.h
* app/apptypes.h
* app/base/Makefile.am
* app/base/base-types.h
* app/core/Makefile.am
* app/core/gimpchannel.c
* app/core/gimpdrawable-equalize.c
* app/core/gimpdrawable-invert.c
* app/pdb/color_cmds.c
* app/widgets/gimphistogramview.c
* tools/pdbgen/Makefile.am
* tools/pdbgen/enums.pl
* tools/pdbgen/pdb/color.pdb: changed accordingly.
2001-05-22 Michael Natterer <mitch@gimp.org>
* app/Makefile.am
......
......@@ -89,8 +89,6 @@ gimp_SOURCES = \
datafiles.h \
floating_sel.c \
floating_sel.h \
gimphistogram.c \
gimphistogram.h \
gimppreviewcache.h \
gimppreviewcache.c \
parasitelist.c \
......@@ -138,8 +136,6 @@ gimp_SOURCES = \
image_new.h \
libgimp_glue.c \
libgimp_glue.h \
lut_funcs.c \
lut_funcs.h \
main.c \
path.c \
path.h \
......
......@@ -119,14 +119,5 @@ typedef enum /*< skip >*/
CURSOR_MODE_CROSSHAIR
} CursorMode;
typedef enum /*< skip >*/
{
GIMP_HISTOGRAM_VALUE = 0,
GIMP_HISTOGRAM_RED = 1,
GIMP_HISTOGRAM_GREEN = 2,
GIMP_HISTOGRAM_BLUE = 3,
GIMP_HISTOGRAM_ALPHA = 4
} GimpHistogramChannel;
#endif /* __APPENUMS_H__ */
......@@ -39,8 +39,6 @@ typedef struct _ColorNotebook ColorNotebook;
typedef struct _GDisplay GDisplay;
typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpImageNewValues GimpImageNewValues;
typedef struct _GimpProgress GimpProgress;
......
......@@ -12,8 +12,12 @@ libappbase_la_SOURCES = \
boundary.h \
brush-scale.c \
brush-scale.h \
gimphistogram.c \
gimphistogram.h \
gimplut.c \
gimplut.h \
lut-funcs.c \
lut-funcs.h \
pixel-processor.c \
pixel-processor.h \
pixel-region.c \
......
......@@ -78,6 +78,16 @@ typedef enum
NEAREST_NEIGHBOR_INTERPOLATION
} InterpolationType;
typedef enum
{
VALUE_LUT,
RED_LUT,
GREEN_LUT,
BLUE_LUT,
ALPHA_LUT,
GRAY_LUT = 0 /*< skip >*/
} ChannelLutType;
/* Transparency representation */
typedef enum /*< skip >*/
{
......@@ -96,11 +106,21 @@ typedef enum /*< skip >*/
LARGE_CHECKS = 2
} GimpCheckSize;
typedef enum /*< skip >*/
{
GIMP_HISTOGRAM_VALUE = 0,
GIMP_HISTOGRAM_RED = 1,
GIMP_HISTOGRAM_GREEN = 2,
GIMP_HISTOGRAM_BLUE = 3,
GIMP_HISTOGRAM_ALPHA = 4
} GimpHistogramChannel;
/* types */
typedef struct _BoundSeg BoundSeg;
typedef struct _GimpHistogram GimpHistogram;
typedef struct _GimpLut GimpLut;
typedef struct _PixelRegionIterator PixelRegionIterator;
......
......@@ -24,20 +24,15 @@
#include <pthread.h>
#endif /* ENABLE_MP */
#include <gtk/gtk.h>
#include <glib.h>
#include "libgimpmath/gimpmath.h"
#include "core/core-types.h"
#include "base/pixel-processor.h"
#include "base/pixel-region.h"
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "base-types.h"
#include "gimphistogram.h"
#include "gimprc.h"
#include "pixel-processor.h"
#include "pixel-region.h"
struct _GimpHistogram
......@@ -347,40 +342,6 @@ gimp_histogram_calculate (GimpHistogram *histogram,
#endif
}
void
gimp_histogram_calculate_drawable (GimpHistogram *histogram,
GimpDrawable *drawable)
{
PixelRegion region;
PixelRegion mask;
gint x1, y1, x2, y2;
gint off_x, off_y;
gboolean no_mask;
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);
if (!no_mask)
{
GimpChannel *sel_mask;
GimpImage *gimage;
gimage = gimp_drawable_gimage (drawable);
sel_mask = gimp_image_get_mask (gimage);
gimp_drawable_offsets (drawable, &off_x, &off_y);
pixel_region_init (&mask, gimp_drawable_data (GIMP_DRAWABLE (sel_mask)),
x1 + off_x, y1 + off_y, (x2 - x1), (y2 - y1), FALSE);
gimp_histogram_calculate (histogram, &region, &mask);
}
else
{
gimp_histogram_calculate (histogram, &region, NULL);
}
}
gdouble
gimp_histogram_get_maximum (GimpHistogram *histogram,
GimpHistogramChannel channel)
......
......@@ -24,11 +24,11 @@
GimpHistogram * gimp_histogram_new (void);
void gimp_histogram_free (GimpHistogram *histogram);
void gimp_histogram_calculate (GimpHistogram *historgam,
PixelRegion *region,
PixelRegion *mask);
void gimp_histogram_calculate_drawable (GimpHistogram *histogram,
GimpDrawable *drawable);
gdouble gimp_histogram_get_maximum (GimpHistogram *histogram,
GimpHistogramChannel channel);
gdouble gimp_histogram_get_count (GimpHistogram *histogram,
......
......@@ -24,27 +24,29 @@
#include "libgimpmath/gimpmath.h"
#include "core/core-types.h"
#include "base/gimplut.h"
#include "base-types.h"
#include "gimphistogram.h"
#include "gimplut.h"
#include "lut-funcs.h"
/* ---------- Brightness/Contrast -----------*/
typedef struct B_C_struct
{
double brightness;
double contrast;
gdouble brightness;
gdouble contrast;
} B_C_struct;
static float
brightness_contrast_lut_func(B_C_struct *data,
int nchannels, int channel, float value)
static gfloat
brightness_contrast_lut_func (B_C_struct *data,
gint nchannels,
gint channel,
gfloat value)
{
float nvalue;
double power;
gfloat nvalue;
gdouble power;
/* return the original value for the alpha channel */
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
......@@ -58,273 +60,344 @@ brightness_contrast_lut_func(B_C_struct *data,
/* apply contrast */
if (data->contrast < 0.0)
{
if (value > 0.5)
nvalue = 1.0 - value;
else
nvalue = value;
if (nvalue < 0.0)
nvalue = 0.0;
nvalue = 0.5 * pow (nvalue * 2.0 , (double) (1.0 + data->contrast));
if (value > 0.5)
value = 1.0 - nvalue;
else
value = nvalue;
}
{
if (value > 0.5)
nvalue = 1.0 - value;
else
nvalue = value;
if (nvalue < 0.0)
nvalue = 0.0;
nvalue = 0.5 * pow (nvalue * 2.0 , (double) (1.0 + data->contrast));
if (value > 0.5)
value = 1.0 - nvalue;
else
value = nvalue;
}
else
{
if (value > 0.5)
nvalue = 1.0 - value;
else
nvalue = value;
if (nvalue < 0.0)
nvalue = 0.0;
power = (data->contrast == 1.0) ? 127 : 1.0 / (1.0 - data->contrast);
nvalue = 0.5 * pow (2.0 * nvalue, power);
if (value > 0.5)
value = 1.0 - nvalue;
else
value = nvalue;
}
{
if (value > 0.5)
nvalue = 1.0 - value;
else
nvalue = value;
if (nvalue < 0.0)
nvalue = 0.0;
power = (data->contrast == 1.0) ? 127 : 1.0 / (1.0 - data->contrast);
nvalue = 0.5 * pow (2.0 * nvalue, power);
if (value > 0.5)
value = 1.0 - nvalue;
else
value = nvalue;
}
return value;
}
GimpLut *
brightness_contrast_lut_new (gdouble brightness,
gdouble contrast,
gint n_channels)
{
GimpLut *lut;
lut = gimp_lut_new ();
brightness_contrast_lut_setup (lut, brightness, contrast, n_channels);
return lut;
}
void
brightness_contrast_lut_setup(GimpLut *lut, double brightness, double contrast,
int nchannels)
brightness_contrast_lut_setup (GimpLut *lut,
gdouble brightness,
gdouble contrast,
gint n_channels)
{
B_C_struct data;
data.brightness = brightness;
data.contrast = contrast;
gimp_lut_setup(lut, (GimpLutFunc) brightness_contrast_lut_func,
(void *) &data, nchannels);
}
data.contrast = contrast;
GimpLut *
brightness_contrast_lut_new(double brightness, double contrast,
int nchannels)
{
GimpLut *lut;
lut = gimp_lut_new();
brightness_contrast_lut_setup(lut, brightness, contrast, nchannels);
return lut;
gimp_lut_setup (lut, (GimpLutFunc) brightness_contrast_lut_func,
(gpointer) &data, n_channels);
}
/* ---------------- invert ------------------ */
static float
invert_lut_func(void *unused,
int nchannels, int channel, float value)
static gfloat
invert_lut_func (gpointer unused,
gint n_channels,
gint channel,
gfloat value)
{
/* don't invert the alpha channel */
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
return value;
return 1.0 - value;
}
void
invert_lut_setup(GimpLut *lut, int nchannels)
{
gimp_lut_setup_exact(lut, (GimpLutFunc) invert_lut_func,
NULL , nchannels);
}
GimpLut *
invert_lut_new(int nchannels)
invert_lut_new (gint n_channels)
{
GimpLut *lut;
lut = gimp_lut_new();
invert_lut_setup(lut, nchannels);
lut = gimp_lut_new ();
invert_lut_setup (lut, n_channels);
return lut;
}
void
invert_lut_setup (GimpLut *lut,
gint n_channels)
{
gimp_lut_setup_exact (lut, (GimpLutFunc) invert_lut_func,
NULL , n_channels);
}
/* ---------------- add (or subract)------------------ */
static float
add_lut_func(double *ammount,
int nchannels, int channel, float value)
static gfloat
add_lut_func (gdouble *amount,
gint n_channels,
gint channel,
gfloat value)
{
/* don't change the alpha channel */
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
return value;
return (value + *ammount);
}
void
add_lut_setup(GimpLut *lut, double ammount, int nchannels)
{
gimp_lut_setup(lut, (GimpLutFunc) add_lut_func,
(void *) &ammount , nchannels);
return (value + *amount);
}
GimpLut *
add_lut_new(double ammount, int nchannels)
add_lut_new (gdouble amount,
gint n_channels)
{
GimpLut *lut;
lut = gimp_lut_new();
add_lut_setup(lut, ammount, nchannels);
lut = gimp_lut_new ();
add_lut_setup (lut, amount, n_channels);
return lut;
}
void
add_lut_setup (GimpLut *lut,
gdouble amount,
gint n_channels)
{
gimp_lut_setup (lut, (GimpLutFunc) add_lut_func,
(gpointer) &amount, n_channels);
}
/* ---------------- intersect (MIN (pixel, value)) ------------------ */
static float
intersect_lut_func(double *min,
int nchannels, int channel, float value)
static gfloat
intersect_lut_func (gdouble *min,
gint n_channels,
gint channel,
gfloat value)
{
/* don't change the alpha channel */
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
return value;
return MIN (value, *min);
}
void
intersect_lut_setup(GimpLut *lut, double value, int nchannels)
{
gimp_lut_setup_exact(lut, (GimpLutFunc) intersect_lut_func,
(void *) &value , nchannels);
}
GimpLut *
intersect_lut_new(double value, int nchannels)
intersect_lut_new (gdouble value,
gint n_channels)
{
GimpLut *lut;
lut = gimp_lut_new();
intersect_lut_setup(lut, value, nchannels);
lut = gimp_lut_new ();
intersect_lut_setup (lut, value, n_channels);
return lut;
}
void
intersect_lut_setup (GimpLut *lut,
gdouble value,
gint n_channels)
{
gimp_lut_setup_exact (lut, (GimpLutFunc) intersect_lut_func,
(gpointer) &value , n_channels);
}
/* ---------------- Threshold ------------------ */
static float
threshold_lut_func(double *min,
int nchannels, int channel, float value)
static gfloat
threshold_lut_func (gdouble *min,
gint n_channels,
gint channel,
gfloat value)
{
/* don't change the alpha channel */
if ((nchannels == 2 || nchannels == 4) && channel == nchannels -1)
if ((n_channels == 2 || n_channels == 4) && channel == n_channels -1)
return value;
if (value < *min)
return 0.0;
return 1.0;
}
void
threshold_lut_setup(GimpLut *lut, double value, int nchannels)
{
gimp_lut_setup_exact(lut, (GimpLutFunc) threshold_lut_func,
(void *) &value , nchannels);
return 1.0;
}
GimpLut *
threshold_lut_new(double value, int nchannels)
threshold_lut_new (gdouble value,
gint n_channels)
{
GimpLut *lut;
lut = gimp_lut_new();
threshold_lut_setup(lut, value, nchannels);
lut = gimp_lut_new ();
threshold_lut_setup (lut, value, n_channels);
return lut;
}
void
threshold_lut_setup (GimpLut *lut,
gdouble value,
gint n_channels)
{
gimp_lut_setup_exact (lut, (GimpLutFunc) threshold_lut_func,
(gpointer) &value , n_channels);
}
/* ------------- levels ------------ */
typedef struct
{
double *gamma;
gdouble *gamma;
int *low_input;
int *high_input;
gint *low_input;
gint *high_input;
int *low_output;
int *high_output;
gint *low_output;
gint *high_output;
} levels_struct;
static float
levels_lut_func(levels_struct *data,
int nchannels, int channel, float value)
static gfloat
levels_lut_func (levels_struct *data,
gint n_channels,
gint channel,
gfloat value)
{
double inten;
int j;
gdouble inten;
gint j;
if (nchannels == 1)
if (n_channels == 1)
j = 0;
else
j = channel + 1;
inten = value;
/* For color images this runs through the loop with j = channel +1
the first time and j = 0 the second time */
/* For bw images this runs through the loop with j = 0 the first and
only time */
* the first time and j = 0 the second time
*
* For bw images this runs through the loop with j = 0 the first and
* only time
*/
for (; j >= 0; j -= (channel + 1))
{
/* don't apply the overall curve to the alpha channel */
if (j == 0 && (nchannels == 2 || nchannels == 4)
&& channel == nchannels -1)
return inten;