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.
24
#include "libgimpmath/gimpmath.h"
26
#include "gimpcolortypes.h"
35
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
36
* @cyan: The Cyan channel of the CMYK value
37
* @magenta: The Magenta channel
38
* @yellow: The Yellow channel
39
* @black: The blacK channel
41
* Very basic initialiser for the internal #GimpCMYK structure. Channel
42
* values are doubles in the range 0 to 1.
45
gimp_cmyk_set (GimpCMYK *cmyk,
51
g_return_if_fail (cmyk != NULL);
60
* gimp_cmyk_set_uchar:
61
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
62
* @cyan: The Cyan channel of the CMYK value
63
* @magenta: The Magenta channel
64
* @yellow: The Yellow channel
65
* @black: The blacK channel
67
* The same as gimp_cmyk_set(), except that channel values are
68
* unsigned chars in the range 0 to 255.
71
gimp_cmyk_set_uchar (GimpCMYK *cmyk,
77
g_return_if_fail (cmyk != NULL);
79
cmyk->c = (gdouble) cyan / 255.0;
80
cmyk->m = (gdouble) magenta / 255.0;
81
cmyk->y = (gdouble) yellow / 255.0;
82
cmyk->k = (gdouble) black / 255.0;
86
* gimp_cmyk_get_uchar:
87
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
88
* @cyan: The Cyan channel of the CMYK value
89
* @magenta: The Magenta channel
90
* @yellow: The Yellow channel
91
* @black: The blacK channel
93
* Retrieve individual channel values from a #GimpCMYK structure. Channel
94
* values are pointers to unsigned chars in the range 0 to 255.
97
gimp_cmyk_get_uchar (const GimpCMYK *cmyk,
103
g_return_if_fail (cmyk != NULL);
105
if (cyan) *cyan = ROUND (CLAMP (cmyk->c, 0.0, 1.0) * 255.0);
106
if (magenta) *magenta = ROUND (CLAMP (cmyk->m, 0.0, 1.0) * 255.0);
107
if (yellow) *yellow = ROUND (CLAMP (cmyk->y, 0.0, 1.0) * 255.0);
108
if (black) *black = ROUND (CLAMP (cmyk->k, 0.0, 1.0) * 255.0);
112
/* CMYKA functions */
116
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
117
* @cyan: The Cyan channel of the CMYK value
118
* @magenta: The Magenta channel
119
* @yellow: The Yellow channel
120
* @black: The blacK channel
121
* @alpha: The Alpha channel
123
* Initialiser for the internal #GimpCMYK structure. Channel values are
124
* doubles in the range 0 to 1.
127
gimp_cmyka_set (GimpCMYK *cmyka,
134
g_return_if_fail (cmyka != NULL);
144
* gimp_cmyka_set_uchar:
145
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
146
* @cyan: The Cyan channel of the CMYK value
147
* @magenta: The Magenta channel
148
* @yellow: The Yellow channel
149
* @black: The blacK channel
150
* @alpha: The Alpha channel
152
* The same as gimp_cmyka_set(), except that channel values are
153
* unsigned chars in the range 0 to 255.
156
gimp_cmyka_set_uchar (GimpCMYK *cmyka,
163
g_return_if_fail (cmyka != NULL);
165
cmyka->c = (gdouble) cyan / 255.0;
166
cmyka->m = (gdouble) magenta / 255.0;
167
cmyka->y = (gdouble) yellow / 255.0;
168
cmyka->k = (gdouble) black / 255.0;
169
cmyka->a = (gdouble) alpha / 255.0;
172
* gimp_cmyka_get_uchar:
173
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
174
* @cyan: The Cyan channel of the CMYK value
175
* @magenta: The Magenta channel
176
* @yellow: The Yellow channel
177
* @black: The blacK channel
178
* @alpha: The Alpha channel
180
* Retrieve individual channel values from a #GimpCMYK structure.
181
* Channel values are pointers to unsigned chars in the range 0 to 255.
184
gimp_cmyka_get_uchar (const GimpCMYK *cmyka,
191
g_return_if_fail (cmyka != NULL);
193
if (cyan) *cyan = ROUND (CLAMP (cmyka->c, 0.0, 1.0) * 255.0);
194
if (magenta) *magenta = ROUND (CLAMP (cmyka->m, 0.0, 1.0) * 255.0);
195
if (yellow) *yellow = ROUND (CLAMP (cmyka->y, 0.0, 1.0) * 255.0);
196
if (black) *black = ROUND (CLAMP (cmyka->k, 0.0, 1.0) * 255.0);
197
if (alpha) *alpha = ROUND (CLAMP (cmyka->a, 0.0, 1.0) * 255.0);