1
/* LIBGIMP - The GIMP Library
2
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
4
* This library is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU Lesser General Public
6
* License as published by the Free Software Foundation; either
7
* version 2 of the License, or (at your option) any later version.
9
* This library is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
* Library General Public License for more details.
14
* You should have received a copy of the GNU Lesser General Public
15
* License along with this library; if not, write to the
16
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
* Boston, MA 02111-1307, USA.
20
#ifndef __GIMP_RGB_H__
21
#define __GIMP_RGB_H__
25
/* For information look into the C source or the html documentation */
28
#define GIMP_TYPE_RGB (gimp_rgb_get_type ())
29
#define GIMP_VALUE_HOLDS_RGB(value) (G_TYPE_CHECK_VALUE_TYPE ((value), GIMP_TYPE_RGB))
31
GType gimp_rgb_get_type (void) G_GNUC_CONST;
34
/* RGB and RGBA color types and operations taken from LibGCK */
38
GIMP_RGB_COMPOSITE_NONE = 0,
39
GIMP_RGB_COMPOSITE_NORMAL,
40
GIMP_RGB_COMPOSITE_BEHIND
41
} GimpRGBCompositeMode;
44
void gimp_rgb_set (GimpRGB *rgb,
48
void gimp_rgb_set_alpha (GimpRGB *rgb,
51
void gimp_rgb_set_uchar (GimpRGB *rgb,
55
void gimp_rgb_get_uchar (const GimpRGB *rgb,
60
gboolean gimp_rgb_parse_name (GimpRGB *rgb,
63
gboolean gimp_rgb_parse_hex (GimpRGB *rgb,
66
gboolean gimp_rgb_parse_css (GimpRGB *rgb,
70
void gimp_rgb_add (GimpRGB *rgb1,
72
void gimp_rgb_subtract (GimpRGB *rgb1,
74
void gimp_rgb_multiply (GimpRGB *rgb1,
76
gdouble gimp_rgb_distance (const GimpRGB *rgb1,
79
gdouble gimp_rgb_max (const GimpRGB *rgb);
80
gdouble gimp_rgb_min (const GimpRGB *rgb);
81
void gimp_rgb_clamp (GimpRGB *rgb);
83
void gimp_rgb_gamma (GimpRGB *rgb,
86
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
87
guchar gimp_rgb_intensity_uchar (const GimpRGB *rgb);
89
void gimp_rgb_composite (GimpRGB *color1,
90
const GimpRGB *color2,
91
GimpRGBCompositeMode mode);
93
/* access to the list of color names */
94
gint gimp_rgb_list_names (const gchar ***names,
98
void gimp_rgba_set (GimpRGB *rgba,
104
void gimp_rgba_set_uchar (GimpRGB *rgba,
109
void gimp_rgba_get_uchar (const GimpRGB *rgba,
115
gboolean gimp_rgba_parse_css (GimpRGB *rgba,
119
void gimp_rgba_add (GimpRGB *rgba1,
120
const GimpRGB *rgba2);
121
void gimp_rgba_subtract (GimpRGB *rgba1,
122
const GimpRGB *rgba2);
123
void gimp_rgba_multiply (GimpRGB *rgba,
126
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
127
const GimpRGB *rgba2);
131
/* Map RGB to intensity */
133
#define GIMP_RGB_INTENSITY_RED 0.30
134
#define GIMP_RGB_INTENSITY_GREEN 0.59
135
#define GIMP_RGB_INTENSITY_BLUE 0.11
136
#define GIMP_RGB_INTENSITY(r,g,b) ((r) * GIMP_RGB_INTENSITY_RED + \
137
(g) * GIMP_RGB_INTENSITY_GREEN + \
138
(b) * GIMP_RGB_INTENSITY_BLUE)
143
#endif /* __GIMP_RGB_H__ */