Commit 4245ab65 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

plug-ins/libgck/gck/gck.h removed the GckRGB color type and all it's

2001-01-01  Michael Natterer  <mitch@gimp.org>

	* plug-ins/libgck/gck/gck.h
	* plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type
	and all it's functions.

	* libgimp/Makefile.am
	* libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color
	type and assorted functions.

	* libgimp/gimpcolorspace.[ch]: colorspace conversion routines for
	the new GimpRGB type. Also taken from LibGCK.

	* libgimp/gimp.h
	* libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include
	it in both files but unavoidable to follow our new "*.c" file include
	policy. This will go away as libgimp will be chopped up into pieces
	anyway.

	* app/apptypes.h
	* app/asupsample.[ch]
	* app/blend.c
	* app/color_transfer.h
	* app/gradient_header.h: removed "color_t" and use GimpRGB instead.

	* plug-ins/Lighting/lighting_apply.c
	* plug-ins/Lighting/lighting_image.c
	* plug-ins/Lighting/lighting_image.h
	* plug-ins/Lighting/lighting_main.c
	* plug-ins/Lighting/lighting_main.h
	* plug-ins/Lighting/lighting_preview.c
	* plug-ins/Lighting/lighting_shade.c
	* plug-ins/Lighting/lighting_shade.h
	* plug-ins/MapObject/mapobject_apply.c
	* plug-ins/MapObject/mapobject_image.c
	* plug-ins/MapObject/mapobject_image.h
	* plug-ins/MapObject/mapobject_main.c
	* plug-ins/MapObject/mapobject_main.h
	* plug-ins/MapObject/mapobject_preview.c
	* plug-ins/MapObject/mapobject_shade.c
	* plug-ins/MapObject/mapobject_shade.h
	* modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g

	* plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor
	version when deciding if to add a missing PDB wrapper.
	(All this compat cruft including libgimp/gimpcompat.h should go
	away ASAP)
parent 40916e09
2001-01-01 Michael Natterer <mitch@gimp.org>
* plug-ins/libgck/gck/gck.h
* plug-ins/libgck/gck/gckcolor.c: removed the GckRGB color type
and all it's functions.
* libgimp/Makefile.am
* libgimp/gimpcolor.[ch]: new files containing the new GimpRGB color
type and assorted functions.
* libgimp/gimpcolorspace.[ch]: colorspace conversion routines for
the new GimpRGB type. Also taken from LibGCK.
* libgimp/gimp.h
* libgimp/gimptypes.h: #include "gimpcolor.h". It's ugly to include
it in both files but unavoidable to follow our new "*.c" file include
policy. This will go away as libgimp will be chopped up into pieces
anyway.
* app/apptypes.h
* app/asupsample.[ch]
* app/blend.c
* app/color_transfer.h
* app/gradient_header.h: removed "color_t" and use GimpRGB instead.
* plug-ins/Lighting/lighting_apply.c
* plug-ins/Lighting/lighting_image.c
* plug-ins/Lighting/lighting_image.h
* plug-ins/Lighting/lighting_main.c
* plug-ins/Lighting/lighting_main.h
* plug-ins/Lighting/lighting_preview.c
* plug-ins/Lighting/lighting_shade.c
* plug-ins/Lighting/lighting_shade.h
* plug-ins/MapObject/mapobject_apply.c
* plug-ins/MapObject/mapobject_image.c
* plug-ins/MapObject/mapobject_image.h
* plug-ins/MapObject/mapobject_main.c
* plug-ins/MapObject/mapobject_main.h
* plug-ins/MapObject/mapobject_preview.c
* plug-ins/MapObject/mapobject_shade.c
* plug-ins/MapObject/mapobject_shade.h
* modules/colorsel_triangle.c: s/GckRGB/GimpRGB/g
* plug-ins/gdyntext/gdyntextcompat.h: check also for GIMP's minor
version when deciding if to add a missing PDB wrapper.
(All this compat cruft including libgimp/gimpcompat.h should go
away ASAP)
2000-12-31 Michael Natterer <mitch@gimp.org>
More preparation for LibGCK removal:
......
......@@ -28,6 +28,9 @@
*/
#include "undo_types.h"
/* these will go into a general purpose library */
#include "libgimp/gimpcolor.h"
#include "libgimp/gimpmatrix.h"
#include "libgimp/gimpvector.h"
#include "libgimp/gimpunit.h"
......
......@@ -46,7 +46,7 @@
typedef struct
{
gchar ready;
color_t color;
GimpRGB color;
} sample_t;
......@@ -64,12 +64,9 @@ static gulong render_sub_pixel (gint max_depth,
gdouble threshold,
gint sub_pixel_size,
render_func_t render_func,
color_t *color,
GimpRGB *color,
gpointer render_data);
static gdouble color_dist (color_t c1,
color_t c2);
/***** Functions *****/
......@@ -91,7 +88,7 @@ adaptive_supersample_area (gint x1,
int xt, xtt, yt; /* Temporary counters */
int sub_pixel_size; /* Numbe of samples per pixel (1D) */
size_t row_size; /* Memory needed for one row */
color_t color; /* Rendered pixel's color */
GimpRGB color; /* Rendered pixel's color */
sample_t tmp_sample; /* For swapping samples */
sample_t *top_row, *bot_row, *tmp_row; /* Sample rows */
sample_t **block; /* Sample block matrix */
......@@ -253,13 +250,13 @@ render_sub_pixel (gint max_depth,
double threshold,
gint sub_pixel_size,
render_func_t render_func,
color_t *color,
GimpRGB *color,
gpointer render_data)
{
int x2, y2; /* Coords of center sample */
double dx1, dy1; /* Delta to upper left sample */
double dx3, dy3; /* Delta to lower right sample */
color_t c1, c2, c3, c4; /* Sample colors */
GimpRGB c1, c2, c3, c4; /* Sample colors */
unsigned long num_samples;
/* Get offsets for corners */
......@@ -338,12 +335,12 @@ render_sub_pixel (gint max_depth,
{
/* Check whether we have tu supersample */
if ((color_dist(c1, c2) >= threshold) ||
(color_dist(c1, c3) >= threshold) ||
(color_dist(c1, c4) >= threshold) ||
(color_dist(c2, c3) >= threshold) ||
(color_dist(c2, c4) >= threshold) ||
(color_dist(c3, c4) >= threshold)) {
if ((gimp_rgba_dist (&c1, &c2) >= threshold) ||
(gimp_rgba_dist (&c1, &c3) >= threshold) ||
(gimp_rgba_dist (&c1, &c4) >= threshold) ||
(gimp_rgba_dist (&c2, &c3) >= threshold) ||
(gimp_rgba_dist (&c2, &c4) >= threshold) ||
(gimp_rgba_dist (&c3, &c4) >= threshold)) {
/* Calc coordinates of center subsample */
x2 = (x1 + x3) / 2;
......@@ -376,13 +373,3 @@ render_sub_pixel (gint max_depth,
return num_samples;
}
static gdouble
color_dist (color_t c1,
color_t c2)
{
return (fabs (c1.r - c2.r) +
fabs (c1.g - c2.g) +
fabs (c1.b - c2.b) +
fabs (c1.a - c2.a));
}
......@@ -24,18 +24,13 @@
#define __ASUPSAMPLE_H__
typedef struct
{
gdouble r, g, b, a; /* Range is [0, 1] */
} color_t;
typedef void (* render_func_t) (gdouble x,
gdouble y,
color_t *color,
GimpRGB *color,
gpointer render_data);
typedef void (* put_pixel_func_t) (gint x,
gint y,
color_t color,
GimpRGB color,
gpointer put_pixel_data);
......
This diff is collapsed.
......@@ -15,23 +15,27 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef __COLOR_TRANSFER_H__
#define __COLOR_TRANSFER_H__
/*************************/
/* color transfer data */
/* for lightening */
extern double highlights_add[];
extern double midtones_add[];
extern double shadows_add[];
extern gdouble highlights_add[];
extern gdouble midtones_add[];
extern gdouble shadows_add[];
/* for darkening */
extern double highlights_sub[];
extern double midtones_sub[];
extern double shadows_sub[];
extern gdouble highlights_sub[];
extern gdouble midtones_sub[];
extern gdouble shadows_sub[];
/* color transfer functions */
void color_transfer_init (void);
void color_transfer_init (void);
#endif /* __COLOR_TRANSFER_H__ */
This diff is collapsed.
......@@ -56,11 +56,11 @@ struct _gradient_t
struct _grad_segment_t
{
double left, middle, right; /* Left pos, midpoint, right pos */
double r0, g0, b0, a0; /* Left color */
double r1, g1, b1, a1; /* Right color */
grad_type_t type; /* Segment's blending function */
grad_color_t color; /* Segment's coloring type */
gdouble left, middle, right; /* Left pos, midpoint, right pos */
gdouble r0, g0, b0, a0; /* Left color */
gdouble r1, g1, b1, a1; /* Right color */
grad_type_t type; /* Segment's blending function */
grad_color_t color; /* Segment's coloring type */
struct _grad_segment_t *prev, *next; /* For linked list of segments */
};
......
This diff is collapsed.
This diff is collapsed.
......@@ -97,8 +97,8 @@ PDB_WRAPPERS_H = \
gimpunit_pdb.h
libgimpi_a_SOURCES = \
gimpenv.c \
gimpenv.h \
gimpcolor.c \
gimpcolor.h \
gimpchainbutton.c \
gimpchainbutton.h \
gimpcolorbutton.c \
......@@ -106,6 +106,8 @@ libgimpi_a_SOURCES = \
gimpcolorspace.h \
gimpdialog.c \
gimpdialog.h \
gimpenv.c \
gimpenv.h \
gimpfileselection.c \
gimpfileselection.h \
gimphelpui.c \
......@@ -154,6 +156,8 @@ libgimp_la_SOURCES = \
gimp.h \
${PDB_WRAPPERS_C} \
${PDB_WRAPPERS_H} \
gimpcolor.c \
gimpcolor.h \
gimpcolorspace.c \
gimpcolorspace.h \
gimpchannel.c \
......@@ -225,6 +229,7 @@ gimpinclude_HEADERS = \
${PDB_WRAPPERS_H} \
gimpchainbutton.h \
gimpchannel.h \
gimpcolor.h \
gimpcolorbutton.h \
gimpcolordisplay.h \
gimpcolorselector.h \
......
......@@ -28,6 +28,7 @@
#include <libgimp/gimptypes.h>
#include <libgimp/gimpchannel.h>
#include <libgimp/gimpcolor.h>
#include <libgimp/gimpcolorspace.h>
#include <libgimp/gimpdrawable.h>
#include <libgimp/gimpfeatures.h>
......
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "config.h"
#include <glib.h>
#include "gimpcolor.h"
#include "gimpmath.h"
/***************************
* channels operations *
***************************/
/* RGB functions */
void
gimp_rgb_set (GimpRGB *rgb,
gdouble r,
gdouble g,
gdouble b)
{
g_return_if_fail (rgb != NULL);
rgb->r = r;
rgb->g = g;
rgb->b = b;
}
void
gimp_rgb_add (GimpRGB *rgb1,
const GimpRGB *rgb2)
{
g_return_if_fail (rgb1 != NULL);
g_return_if_fail (rgb2 != NULL);
rgb1->r = rgb1->r + rgb2->r;
rgb1->g = rgb1->g + rgb2->g;
rgb1->b = rgb1->b + rgb2->b;
}
void
gimp_rgb_sub (GimpRGB *rgb1,
const GimpRGB *rgb2)
{
g_return_if_fail (rgb1 != NULL);
g_return_if_fail (rgb2 != NULL);
rgb1->r = rgb1->r - rgb2->r;
rgb1->g = rgb1->g - rgb2->g;
rgb1->b = rgb1->b - rgb2->b;
}
void
gimp_rgb_mul (GimpRGB *rgb,
gdouble factor)
{
g_return_if_fail (rgb != NULL);
rgb->r *= factor;
rgb->g *= factor;
rgb->b *= factor;
}
gdouble
gimp_rgb_dist (const GimpRGB *rgb1,
const GimpRGB *rgb2)
{
g_return_val_if_fail (rgb1 != NULL, 0.0);
g_return_val_if_fail (rgb2 != NULL, 0.0);
return (fabs (rgb1->r - rgb2->r) +
fabs (rgb1->g - rgb2->g) +
fabs (rgb1->b - rgb2->b));
}
gdouble
gimp_rgb_max (const GimpRGB *rgb)
{
g_return_val_if_fail (rgb != NULL, 0.0);
return MAX (rgb->r, MAX (rgb->g, rgb->b));
}
gdouble
gimp_rgb_min (const GimpRGB *rgb)
{
g_return_val_if_fail (rgb != NULL, 0.0);
return MIN (rgb->r, MIN (rgb->g, rgb->b));
}
void
gimp_rgb_clamp (GimpRGB *rgb)
{
g_return_if_fail (rgb != NULL);
rgb->r = CLAMP (rgb->r, 0.0, 1.0);
rgb->g = CLAMP (rgb->g, 0.0, 1.0);
rgb->b = CLAMP (rgb->b, 0.0, 1.0);
}
void
gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma)
{
gdouble ig;
g_return_if_fail (rgb != NULL);
if (gamma != 0.0)
ig = 1.0 / gamma;
else
ig = 0.0;
rgb->r = pow (rgb->r, ig);
rgb->g = pow (rgb->g, ig);
rgb->b = pow (rgb->b, ig);
}
/* RGBA functions */
void
gimp_rgba_set (GimpRGB *rgba,
gdouble r,
gdouble g,
gdouble b,
gdouble a)
{
g_return_if_fail (rgba != NULL);
rgba->r = r;
rgba->g = g;
rgba->b = b;
rgba->a = a;
}
void
gimp_rgba_add (GimpRGB *rgba1,
const GimpRGB *rgba2)
{
g_return_if_fail (rgba1 != NULL);
g_return_if_fail (rgba2 != NULL);
rgba1->r = rgba1->r + rgba2->r;
rgba1->g = rgba1->g + rgba2->g;
rgba1->b = rgba1->b + rgba2->b;
rgba1->a = rgba1->a + rgba2->a;
}
void
gimp_rgba_sub (GimpRGB *rgba1,
const GimpRGB *rgba2)
{
g_return_if_fail (rgba1 != NULL);
g_return_if_fail (rgba2 != NULL);
rgba1->r = rgba1->r - rgba2->r;
rgba1->g = rgba1->g - rgba2->g;
rgba1->b = rgba1->b - rgba2->b;
rgba1->a = rgba1->a - rgba2->a;
}
void
gimp_rgba_mul (GimpRGB *rgba,
gdouble factor)
{
g_return_if_fail (rgba != NULL);
rgba->r = rgba->r * factor;
rgba->g = rgba->g * factor;
rgba->b = rgba->b * factor;
rgba->a = rgba->a * factor;
}
gdouble
gimp_rgba_dist (const GimpRGB *rgba1,
const GimpRGB *rgba2)
{
g_return_val_if_fail (rgba1 != NULL, 0.0);
g_return_val_if_fail (rgba2 != NULL, 0.0);
return (fabs (rgba1->r - rgba2->r) + fabs (rgba1->g - rgba2->g) +
fabs (rgba1->b - rgba2->b) + fabs (rgba1->a - rgba2->a));
}
/* These two are probably not needed */
gdouble
gimp_rgba_max (const GimpRGB *rgba)
{
g_return_val_if_fail (rgba != NULL, 0.0);
return MAX (rgba->r, MAX (rgba->g, MAX (rgba->b, rgba->a)));
}
gdouble
gimp_rgba_min (const GimpRGB *rgba)
{
g_return_val_if_fail (rgba != NULL, 0.0);
return MIN (rgba->r, MIN (rgba->g, MIN (rgba->b, rgba->a)));
}
void
gimp_rgba_clamp (GimpRGB *rgba)
{
g_return_if_fail (rgba != NULL);
rgba->r = CLAMP (rgba->r, 0.0, 1.0);
rgba->g = CLAMP (rgba->g, 0.0, 1.0);
rgba->b = CLAMP (rgba->b, 0.0, 1.0);
rgba->a = CLAMP (rgba->a, 0.0, 1.0);
}
void
gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma)
{
gdouble ig;
g_return_if_fail (rgba != NULL);
if (gamma != 0.0)
ig = 1.0 / gamma;
else
(ig = 0.0);
rgba->r = pow (rgba->r, ig);
rgba->g = pow (rgba->g, ig);
rgba->b = pow (rgba->b, ig);
rgba->a = pow (rgba->a, ig);
}
/* LIBGIMP - The GIMP Library
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GIMP_COLOR_H__
#define __GIMP_COLOR_H__
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* For information look into the C source or the html documentation */
/* RGB and RGBA color types and operations taken from LibGCK */
typedef struct _GimpRGB GimpRGB;
struct _GimpRGB
{
gdouble r, g, b, a;
};
void gimp_rgb_set (GimpRGB *rgb,
gdouble r,
gdouble g,
gdouble b);
void gimp_rgb_add (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_sub (GimpRGB *rgb1,
const GimpRGB *rgb2);
void gimp_rgb_mul (GimpRGB *rgb1,
gdouble factor);
gdouble gimp_rgb_dist (const GimpRGB *rgb1,
const GimpRGB *rgb2);
gdouble gimp_rgb_max (const GimpRGB *rgb);
gdouble gimp_rgb_min (const GimpRGB *rgb);
void gimp_rgb_clamp (GimpRGB *rgb);
void gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma);
void gimp_rgba_set (GimpRGB *rgba,
gdouble r,
gdouble g,
gdouble b,
gdouble a);
void gimp_rgba_add (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_sub (GimpRGB *rgba1,
const GimpRGB *rgba2);
void gimp_rgba_mul (GimpRGB *rgba,
gdouble factor);
gdouble gimp_rgba_dist (const GimpRGB *rgba1,
const GimpRGB *rgba2);
gdouble gimp_rgba_max (const GimpRGB *rgba);
gdouble gimp_rgba_min (const GimpRGB *rgba);
void gimp_rgba_clamp (GimpRGB *rgba);
void gimp_rgba_gamma (GimpRGB *rgba,
gdouble gamma);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif /* __GIMP_COLOR_H__ */
......@@ -19,12 +19,343 @@
#include <glib.h>
#include "gimpcolor.h"
#include "gimpcolorspace.h"
#include "gimpmath.h"
/*********************************
* color conversion routines *
*********************************/
/* GimpRGB functions */