mirror of https://github.com/GNOME/gimp.git
libgimpcolor/Makefile.am libgimpcolor/makefile.msc new files that define a
2003-07-14 Sven Neumann <sven@gimp.org> * libgimpcolor/Makefile.am * libgimpcolor/makefile.msc * libgimpcolor/gimpcmyk.[ch]: new files that define a GimpCMYK structure similar to GimpRGB. * libgimpcolor/gimpcolortypes.h: added the GimpCMYK typedef. * libgimpcolor/gimpcolorspace.[ch]: added conversions between RGB and CMYK. This implementation is the naive approach without any color calibration whatsoever. * libgimpcolor/gimphsv.[ch] * libgimpcolor/gimprgb.[ch]: purely cosmetic changes.
This commit is contained in:
parent
68c0a8d647
commit
f357b2cde0
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2003-07-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/Makefile.am
|
||||
* libgimpcolor/makefile.msc
|
||||
* libgimpcolor/gimpcmyk.[ch]: new files that define a GimpCMYK
|
||||
structure similar to GimpRGB.
|
||||
|
||||
* libgimpcolor/gimpcolortypes.h: added the GimpCMYK typedef.
|
||||
|
||||
* libgimpcolor/gimpcolorspace.[ch]: added conversions between RGB
|
||||
and CMYK. This implementation is the naive approach without any
|
||||
color calibration whatsoever.
|
||||
|
||||
* libgimpcolor/gimphsv.[ch]
|
||||
* libgimpcolor/gimprgb.[ch]: purely cosmetic changes.
|
||||
|
||||
2003-07-14 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
Argh...
|
||||
|
|
|
@ -1,3 +1,12 @@
|
|||
2003-07-14 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* libgimpcolor/libgimpcolor-docs.sgml
|
||||
* libgimpcolor/libgimpcolor-sections.txt
|
||||
* libgimpcolor/tmpl/gimpcmyk.sgml
|
||||
* libgimpcolor/tmpl/gimpcolorspace.sgml
|
||||
* libgimpcolor/tmpl/gimphsv.sgml
|
||||
* libgimpcolor/tmpl/gimprgb.sgml: updated for new CMYK functions.
|
||||
|
||||
2003-07-10 Michael Natterer <mitch@gimp.org>
|
||||
|
||||
* includes.txt: s:libgimp/gimpintl.h:gimp-intl.h:
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
"http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
|
||||
<!ENTITY GimpRGB SYSTEM "xml/gimprgb.xml">
|
||||
<!ENTITY GimpHSV SYSTEM "xml/gimphsv.xml">
|
||||
<!ENTITY GimpCMYK SYSTEM "xml/gimpcmyk.xml">
|
||||
<!ENTITY GimpColorSpace SYSTEM "xml/gimpcolorspace.xml">
|
||||
<!ENTITY GimpAdaptiveSupersample SYSTEM "xml/gimpadaptivesupersample.xml">
|
||||
<!ENTITY GimpBilinear SYSTEM "xml/gimpbilinear.xml">
|
||||
|
@ -19,6 +20,7 @@
|
|||
<title>GIMP Color Library</title>
|
||||
&GimpRGB;
|
||||
&GimpHSV;
|
||||
&GimpCMYK;
|
||||
&GimpColorSpace;
|
||||
&GimpAdaptiveSupersample;
|
||||
&GimpBilinear;
|
||||
|
|
|
@ -4,19 +4,35 @@
|
|||
GimpHSL
|
||||
gimp_rgb_to_hsv
|
||||
gimp_rgb_to_hsl
|
||||
gimp_rgb_to_cmyk
|
||||
gimp_hsv_to_rgb
|
||||
gimp_hsl_to_rgb
|
||||
gimp_cmyk_to_rgb
|
||||
gimp_rgb_to_hwb
|
||||
gimp_hwb_to_rgb
|
||||
gimp_rgb_to_hsv_int
|
||||
gimp_hsv_to_rgb_int
|
||||
gimp_rgb_to_hls_int
|
||||
gimp_rgb_to_cmyk_int
|
||||
gimp_cmyk_to_rgb_int
|
||||
gimp_rgb_to_l_int
|
||||
gimp_hls_to_rgb_int
|
||||
gimp_rgb_to_hsv4
|
||||
gimp_hsv_to_rgb4
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimpcmyk</FILE>
|
||||
<TITLE>GimpCMYK</TITLE>
|
||||
GimpCMYK
|
||||
gimp_cmyk_set
|
||||
gimp_cmyk_set_uchar
|
||||
gimp_cmyk_get_uchar
|
||||
gimp_cmyka_set
|
||||
gimp_cmyka_set_uchar
|
||||
gimp_cmyka_get_uchar
|
||||
</SECTION>
|
||||
|
||||
<SECTION>
|
||||
<FILE>gimphsv</FILE>
|
||||
<TITLE>GimpHSV</TITLE>
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
<!-- ##### SECTION Title ##### -->
|
||||
GimpCMYK
|
||||
|
||||
<!-- ##### SECTION Short_Description ##### -->
|
||||
|
||||
|
||||
<!-- ##### SECTION Long_Description ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### SECTION See_Also ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
<!-- ##### STRUCT GimpCMYK ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@c:
|
||||
@m:
|
||||
@y:
|
||||
@k:
|
||||
@a:
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyk_set ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyk:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyk_set_uchar ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyk:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyk_get_uchar ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyk:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyka_set ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyka:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyka_set_uchar ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyka:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyka_get_uchar ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyka:
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
@alpha:
|
||||
|
||||
|
|
@ -43,10 +43,15 @@ different color spaces.
|
|||
|
||||
@rgb:
|
||||
@hsl:
|
||||
<!-- # Unused Parameters # -->
|
||||
@hue:
|
||||
@saturation:
|
||||
@lightness:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_to_cmyk ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@rgb:
|
||||
@cmyk:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_hsv_to_rgb ##### -->
|
||||
|
@ -65,10 +70,15 @@ different color spaces.
|
|||
|
||||
@hsl:
|
||||
@rgb:
|
||||
<!-- # Unused Parameters # -->
|
||||
@hue:
|
||||
@saturation:
|
||||
@lightness:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyk_to_rgb ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cmyk:
|
||||
@rgb:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_to_hwb ##### -->
|
||||
|
@ -123,6 +133,28 @@ different color spaces.
|
|||
@blue:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_to_cmyk_int ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
@black:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_cmyk_to_rgb_int ##### -->
|
||||
<para>
|
||||
|
||||
</para>
|
||||
|
||||
@cyan:
|
||||
@magenta:
|
||||
@yellow:
|
||||
@black:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_to_l_int ##### -->
|
||||
<para>
|
||||
|
||||
|
|
|
@ -30,9 +30,9 @@ GimpHSV
|
|||
</para>
|
||||
|
||||
@hsv:
|
||||
@h:
|
||||
@s:
|
||||
@v:
|
||||
@hue:
|
||||
@saturation:
|
||||
@value:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_hsv_clamp ##### -->
|
||||
|
@ -49,9 +49,9 @@ GimpHSV
|
|||
</para>
|
||||
|
||||
@hsva:
|
||||
@h:
|
||||
@s:
|
||||
@v:
|
||||
@a:
|
||||
@hue:
|
||||
@saturation:
|
||||
@value:
|
||||
@alpha:
|
||||
|
||||
|
||||
|
|
|
@ -39,9 +39,9 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgb:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_set_alpha ##### -->
|
||||
|
@ -50,7 +50,7 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgb:
|
||||
@a:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_set_uchar ##### -->
|
||||
|
@ -59,9 +59,9 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgb:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_get_uchar ##### -->
|
||||
|
@ -70,9 +70,9 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgb:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgb_add ##### -->
|
||||
|
@ -181,10 +181,10 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgba:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@a:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgba_set_uchar ##### -->
|
||||
|
@ -193,10 +193,10 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgba:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@a:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgba_get_uchar ##### -->
|
||||
|
@ -205,10 +205,10 @@ GimpRGB
|
|||
</para>
|
||||
|
||||
@rgba:
|
||||
@r:
|
||||
@g:
|
||||
@b:
|
||||
@a:
|
||||
@red:
|
||||
@green:
|
||||
@blue:
|
||||
@alpha:
|
||||
|
||||
|
||||
<!-- ##### FUNCTION gimp_rgba_add ##### -->
|
||||
|
|
|
@ -64,6 +64,8 @@ libgimpcolor_1_3_la_SOURCES = \
|
|||
gimpadaptivesupersample.h \
|
||||
gimpbilinear.c \
|
||||
gimpbilinear.h \
|
||||
gimpcmyk.c \
|
||||
gimpcmyk.h \
|
||||
gimpcolorspace.c \
|
||||
gimpcolorspace.h \
|
||||
gimphsv.c \
|
||||
|
@ -76,6 +78,7 @@ libgimpcolorinclude_HEADERS = \
|
|||
gimpcolortypes.h \
|
||||
gimpadaptivesupersample.h \
|
||||
gimpbilinear.h \
|
||||
gimpcmyk.h \
|
||||
gimpcolorspace.h \
|
||||
gimphsv.h \
|
||||
gimprgb.h
|
||||
|
|
|
@ -0,0 +1,130 @@
|
|||
/* 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 "libgimpmath/gimpmath.h"
|
||||
|
||||
#include "gimpcolortypes.h"
|
||||
|
||||
#include "gimpcmyk.h"
|
||||
|
||||
|
||||
/* CMYK functions */
|
||||
|
||||
void
|
||||
gimp_cmyk_set (GimpCMYK *cmyk,
|
||||
gdouble c,
|
||||
gdouble m,
|
||||
gdouble y,
|
||||
gdouble k)
|
||||
{
|
||||
g_return_if_fail (cmyk != NULL);
|
||||
|
||||
cmyk->c = c;
|
||||
cmyk->m = m;
|
||||
cmyk->y = y;
|
||||
cmyk->k = k;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyk_set_uchar (GimpCMYK *cmyk,
|
||||
guchar c,
|
||||
guchar m,
|
||||
guchar y,
|
||||
guchar k)
|
||||
{
|
||||
g_return_if_fail (cmyk != NULL);
|
||||
|
||||
cmyk->c = (gdouble) c / 255.0;
|
||||
cmyk->m = (gdouble) m / 255.0;
|
||||
cmyk->y = (gdouble) y / 255.0;
|
||||
cmyk->k = (gdouble) k / 255.0;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyk_get_uchar (const GimpCMYK *cmyk,
|
||||
guchar *c,
|
||||
guchar *m,
|
||||
guchar *y,
|
||||
guchar *k)
|
||||
{
|
||||
g_return_if_fail (cmyk != NULL);
|
||||
|
||||
if (c) *c = ROUND (CLAMP (cmyk->c, 0.0, 1.0) * 255.0);
|
||||
if (m) *m = ROUND (CLAMP (cmyk->m, 0.0, 1.0) * 255.0);
|
||||
if (y) *y = ROUND (CLAMP (cmyk->y, 0.0, 1.0) * 255.0);
|
||||
if (k) *k = ROUND (CLAMP (cmyk->k, 0.0, 1.0) * 255.0);
|
||||
}
|
||||
|
||||
|
||||
/* CMYKA functions */
|
||||
|
||||
void
|
||||
gimp_cmyka_set (GimpCMYK *cmyka,
|
||||
gdouble c,
|
||||
gdouble m,
|
||||
gdouble y,
|
||||
gdouble k,
|
||||
gdouble a)
|
||||
{
|
||||
g_return_if_fail (cmyka != NULL);
|
||||
|
||||
cmyka->c = c;
|
||||
cmyka->m = m;
|
||||
cmyka->y = y;
|
||||
cmyka->k = k;
|
||||
cmyka->a = a;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyka_set_uchar (GimpCMYK *cmyka,
|
||||
guchar c,
|
||||
guchar m,
|
||||
guchar y,
|
||||
guchar k,
|
||||
guchar a)
|
||||
{
|
||||
g_return_if_fail (cmyka != NULL);
|
||||
|
||||
cmyka->c = (gdouble) c / 255.0;
|
||||
cmyka->m = (gdouble) m / 255.0;
|
||||
cmyka->y = (gdouble) y / 255.0;
|
||||
cmyka->k = (gdouble) k / 255.0;
|
||||
cmyka->a = (gdouble) a / 255.0;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyka_get_uchar (const GimpCMYK *cmyka,
|
||||
guchar *c,
|
||||
guchar *m,
|
||||
guchar *y,
|
||||
guchar *k,
|
||||
guchar *a)
|
||||
{
|
||||
g_return_if_fail (cmyka != NULL);
|
||||
|
||||
if (c) *c = ROUND (CLAMP (cmyka->c, 0.0, 1.0) * 255.0);
|
||||
if (m) *m = ROUND (CLAMP (cmyka->m, 0.0, 1.0) * 255.0);
|
||||
if (y) *y = ROUND (CLAMP (cmyka->y, 0.0, 1.0) * 255.0);
|
||||
if (k) *k = ROUND (CLAMP (cmyka->k, 0.0, 1.0) * 255.0);
|
||||
if (a) *a = ROUND (CLAMP (cmyka->a, 0.0, 1.0) * 255.0);
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
/* 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_CMYK_H__
|
||||
#define __GIMP_CMYK_H__
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
||||
/* For information look into the C source or the html documentation */
|
||||
|
||||
|
||||
void gimp_cmyk_set (GimpCMYK *cmyk,
|
||||
gdouble cyan,
|
||||
gdouble magenta,
|
||||
gdouble yellow,
|
||||
gdouble black);
|
||||
void gimp_cmyk_set_uchar (GimpCMYK *cmyk,
|
||||
guchar cyan,
|
||||
guchar magenta,
|
||||
guchar yellow,
|
||||
guchar black);
|
||||
void gimp_cmyk_get_uchar (const GimpCMYK *cmyk,
|
||||
guchar *cyan,
|
||||
guchar *magenta,
|
||||
guchar *yellow,
|
||||
guchar *black);
|
||||
|
||||
void gimp_cmyka_set (GimpCMYK *cmyka,
|
||||
gdouble cyan,
|
||||
gdouble magenta,
|
||||
gdouble yellow,
|
||||
gdouble black,
|
||||
gdouble alpha);
|
||||
void gimp_cmyka_set_uchar (GimpCMYK *cmyka,
|
||||
guchar cyan,
|
||||
guchar magenta,
|
||||
guchar yellow,
|
||||
guchar black,
|
||||
guchar alpha);
|
||||
void gimp_cmyka_get_uchar (const GimpCMYK *cmyka,
|
||||
guchar *cyan,
|
||||
guchar *magenta,
|
||||
guchar *yellow,
|
||||
guchar *black,
|
||||
guchar *alpha);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GIMP_CMYK_H__ */
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -160,6 +160,7 @@ gimp_hsv_to_rgb (const GimpHSV *hsv,
|
|||
rgb->a = hsv->a;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsl (const GimpRGB *rgb,
|
||||
GimpHSL *hsl)
|
||||
|
@ -270,6 +271,73 @@ gimp_hsl_to_rgb (const GimpHSL *hsl,
|
|||
rgb->a = hsl->a;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_rgb_to_cmyk (const GimpRGB *rgb,
|
||||
GimpCMYK *cmyk)
|
||||
{
|
||||
gdouble c, m, y, k;
|
||||
|
||||
g_return_if_fail (rgb != NULL);
|
||||
g_return_if_fail (cmyk != NULL);
|
||||
|
||||
c = 1.0 - rgb->r;
|
||||
m = 1.0 - rgb->g;
|
||||
y = 1.0 - rgb->b;
|
||||
|
||||
k = 1.0;
|
||||
if (c < k) k = c;
|
||||
if (m < k) k = m;
|
||||
if (y < k) k = y;
|
||||
|
||||
if (k < 1.0)
|
||||
{
|
||||
cmyk->c = (c - k) / (1.0 - k);
|
||||
cmyk->m = (m - k) / (1.0 - k);
|
||||
cmyk->y = (y - k) / (1.0 - k);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmyk->c = 0.0;
|
||||
cmyk->m = 0.0;
|
||||
cmyk->y = 0.0;
|
||||
}
|
||||
|
||||
cmyk->k = k;
|
||||
cmyk->a = rgb->a;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyk_to_rgb (const GimpCMYK *cmyk,
|
||||
GimpRGB *rgb)
|
||||
{
|
||||
gdouble c, m, y, k;
|
||||
|
||||
g_return_if_fail (cmyk != NULL);
|
||||
g_return_if_fail (rgb != NULL);
|
||||
|
||||
k = cmyk->k;
|
||||
|
||||
if (k < 1.0)
|
||||
{
|
||||
c = cmyk->c * (1.0 - k) + k;
|
||||
m = cmyk->m * (1.0 - k) + k;
|
||||
y = cmyk->y * (1.0 - k) + k;
|
||||
}
|
||||
else
|
||||
{
|
||||
c = 1.0;
|
||||
m = 1.0;
|
||||
y = 1.0;
|
||||
}
|
||||
|
||||
rgb->r = 1.0 - c;
|
||||
rgb->g = 1.0 - m;
|
||||
rgb->b = 1.0 - y;
|
||||
rgb->a = cmyk->a;
|
||||
}
|
||||
|
||||
|
||||
#define GIMP_RETURN_RGB(x, y, z) { rgb->r = x; rgb->g = y; rgb->b = z; return; }
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -305,7 +373,7 @@ gimp_rgb_to_hwb (const GimpRGB *rgb,
|
|||
{
|
||||
f = (R == w) ? G - B : ((G == w) ? B - R : R - G);
|
||||
i = (R == w) ? 3.0 : ((G == w) ? 5.0 : 1.0);
|
||||
|
||||
|
||||
*hue = (360.0 / 6.0) * (i - f / (v - w));
|
||||
*whiteness = w;
|
||||
*blackness = b;
|
||||
|
@ -322,7 +390,7 @@ gimp_hwb_to_rgb (gdouble hue,
|
|||
* blackness are given on [0, 1].
|
||||
* RGB are each returned on [0, 1].
|
||||
*/
|
||||
|
||||
|
||||
gdouble h = hue, w = whiteness, b = blackness, v, n, f;
|
||||
gint i;
|
||||
|
||||
|
@ -344,7 +412,7 @@ gimp_hwb_to_rgb (gdouble hue,
|
|||
f = 1.0 - f; /* if i is odd */
|
||||
|
||||
n = w + f * (v - w); /* linear interpolation between w and v */
|
||||
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 6:
|
||||
|
@ -636,9 +704,58 @@ gimp_hls_to_rgb_int (gint *hue,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gimp_rgb_to_cmyk_int (gint *red,
|
||||
gint *green,
|
||||
gint *blue,
|
||||
gint *black)
|
||||
{
|
||||
gint c, m, y, k;
|
||||
|
||||
c = 255 - *red;
|
||||
m = 255 - *green;
|
||||
y = 255 - *blue;
|
||||
|
||||
k = 255;
|
||||
if (c < k) k = c;
|
||||
if (m < k) k = m;
|
||||
if (y < k) k = y;
|
||||
|
||||
*red = ((c - k) << 8) / (256 - k);
|
||||
*green = ((m - k) << 8) / (256 - k);
|
||||
*blue = ((y - k) << 8) / (256 - k);
|
||||
*black = k;
|
||||
}
|
||||
|
||||
void
|
||||
gimp_cmyk_to_rgb_int (gint *cyan,
|
||||
gint *magenta,
|
||||
gint *yellow,
|
||||
gint *black)
|
||||
{
|
||||
gint c, m, y, k;
|
||||
|
||||
c = *cyan;
|
||||
m = *magenta;
|
||||
y = *yellow;
|
||||
k = *black;
|
||||
|
||||
if (k)
|
||||
{
|
||||
c = ((c * (256 - k)) >> 8) + k;
|
||||
m = ((m * (256 - k)) >> 8) + k;
|
||||
y = ((y * (256 - k)) >> 8) + k;
|
||||
}
|
||||
|
||||
*cyan = 255 - c;
|
||||
*magenta = 255 - m;
|
||||
*yellow = 255 - y;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *value)
|
||||
{
|
||||
gdouble red, green, blue;
|
||||
|
@ -700,7 +817,7 @@ gimp_rgb_to_hsv4 (guchar *rgb,
|
|||
}
|
||||
|
||||
void
|
||||
gimp_hsv_to_rgb4 (guchar *rgb,
|
||||
gimp_hsv_to_rgb4 (guchar *rgb,
|
||||
gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble value)
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -30,24 +30,28 @@ G_BEGIN_DECLS
|
|||
|
||||
/* GimpRGB function */
|
||||
|
||||
void gimp_rgb_to_hsv (const GimpRGB *rgb,
|
||||
GimpHSV *hsv);
|
||||
void gimp_rgb_to_hsl (const GimpRGB *rgb,
|
||||
GimpHSL *hsl);
|
||||
void gimp_rgb_to_hsv (const GimpRGB *rgb,
|
||||
GimpHSV *hsv);
|
||||
void gimp_rgb_to_hsl (const GimpRGB *rgb,
|
||||
GimpHSL *hsl);
|
||||
void gimp_rgb_to_cmyk (const GimpRGB *rgb,
|
||||
GimpCMYK *cmyk);
|
||||
|
||||
void gimp_hsv_to_rgb (const GimpHSV *hsv,
|
||||
GimpRGB *rgb);
|
||||
void gimp_hsl_to_rgb (const GimpHSL *hsl,
|
||||
GimpRGB *rgb);
|
||||
void gimp_hsv_to_rgb (const GimpHSV *hsv,
|
||||
GimpRGB *rgb);
|
||||
void gimp_hsl_to_rgb (const GimpHSL *hsl,
|
||||
GimpRGB *rgb);
|
||||
void gimp_cmyk_to_rgb (const GimpCMYK *cmyk,
|
||||
GimpRGB *rgb);
|
||||
|
||||
void gimp_rgb_to_hwb (const GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *whiteness,
|
||||
gdouble *blackness);
|
||||
void gimp_hwb_to_rgb (gdouble hue,
|
||||
gdouble whiteness,
|
||||
gdouble blackness,
|
||||
GimpRGB *rgb);
|
||||
void gimp_rgb_to_hwb (const GimpRGB *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *whiteness,
|
||||
gdouble *blackness);
|
||||
void gimp_hwb_to_rgb (gdouble hue,
|
||||
gdouble whiteness,
|
||||
gdouble blackness,
|
||||
GimpRGB *rgb);
|
||||
|
||||
|
||||
/* gint functions */
|
||||
|
@ -59,6 +63,15 @@ void gimp_hsv_to_rgb_int (gint *hue /* returns red */,
|
|||
gint *saturation /* returns green */,
|
||||
gint *value /* returns blue */);
|
||||
|
||||
void gimp_rgb_to_cmyk_int (gint *red /* returns cyan */,
|
||||
gint *green /* returns magenta */,
|
||||
gint *blue /* returns yellow */,
|
||||
gint *black /* ignored as input */);
|
||||
void gimp_cmyk_to_rgb_int (gint *cyan /* returns red */,
|
||||
gint *magenta /* returns green */,
|
||||
gint *yellow /* returns blue */,
|
||||
gint *black /* not changed */);
|
||||
|
||||
void gimp_rgb_to_hls_int (gint *red /* returns hue */,
|
||||
gint *green /* returns lightness */,
|
||||
gint *blue /* returns saturation */);
|
||||
|
@ -72,9 +85,9 @@ void gimp_hls_to_rgb_int (gint *hue /* returns red */,
|
|||
|
||||
/* gdouble functions */
|
||||
|
||||
void gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
void gimp_rgb_to_hsv4 (guchar *rgb,
|
||||
gdouble *hue,
|
||||
gdouble *saturation,
|
||||
gdouble *value);
|
||||
void gimp_hsv_to_rgb4 (guchar *rgb,
|
||||
gdouble hue,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -29,9 +29,10 @@ G_BEGIN_DECLS
|
|||
* but GimpRGB appears in too many header files...
|
||||
*/
|
||||
|
||||
typedef struct _GimpRGB GimpRGB;
|
||||
typedef struct _GimpHSV GimpHSV;
|
||||
typedef struct _GimpHSL GimpHSL;
|
||||
typedef struct _GimpRGB GimpRGB;
|
||||
typedef struct _GimpHSV GimpHSV;
|
||||
typedef struct _GimpHSL GimpHSL;
|
||||
typedef struct _GimpCMYK GimpCMYK;
|
||||
|
||||
struct _GimpRGB
|
||||
{
|
||||
|
@ -48,6 +49,11 @@ struct _GimpHSL
|
|||
gdouble h, s, l, a;
|
||||
};
|
||||
|
||||
struct _GimpCMYK
|
||||
{
|
||||
gdouble c, m, y, k, a;
|
||||
};
|
||||
|
||||
|
||||
typedef void (* GimpRenderFunc) (gdouble x,
|
||||
gdouble y,
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -26,16 +26,16 @@ G_BEGIN_DECLS
|
|||
|
||||
|
||||
void gimp_hsv_set (GimpHSV *hsv,
|
||||
gdouble h,
|
||||
gdouble s,
|
||||
gdouble v);
|
||||
gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble value);
|
||||
void gimp_hsv_clamp (GimpHSV *hsv);
|
||||
|
||||
void gimp_hsva_set (GimpHSV *hsva,
|
||||
gdouble h,
|
||||
gdouble s,
|
||||
gdouble v,
|
||||
gdouble a);
|
||||
gdouble hue,
|
||||
gdouble saturation,
|
||||
gdouble value,
|
||||
gdouble alpha);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -203,7 +203,7 @@ gimp_rgb_composite (GimpRGB *color1,
|
|||
|
||||
g_return_if_fail (color1 != NULL);
|
||||
g_return_if_fail (color2 != NULL);
|
||||
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
case GIMP_RGB_COMPOSITE_NONE:
|
||||
|
@ -224,7 +224,7 @@ gimp_rgb_composite (GimpRGB *color1,
|
|||
color1->a = factor + color2->a;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GIMP_RGB_COMPOSITE_BEHIND:
|
||||
/* put color2 below color1 */
|
||||
if (color1->a < 1.0)
|
||||
|
@ -325,7 +325,7 @@ gimp_rgba_multiply (GimpRGB *rgba,
|
|||
}
|
||||
|
||||
gdouble
|
||||
gimp_rgba_distance (const GimpRGB *rgba1,
|
||||
gimp_rgba_distance (const GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2)
|
||||
{
|
||||
g_return_val_if_fail (rgba1 != NULL, 0.0);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
/* LIBGIMP - The GIMP Library
|
||||
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
|
||||
/* 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
|
||||
*
|
||||
* 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
|
||||
|
@ -36,19 +36,19 @@ typedef enum
|
|||
|
||||
|
||||
void gimp_rgb_set (GimpRGB *rgb,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b);
|
||||
gdouble red,
|
||||
gdouble green,
|
||||
gdouble blue);
|
||||
void gimp_rgb_set_alpha (GimpRGB *rgb,
|
||||
gdouble a);
|
||||
gdouble alpha);
|
||||
void gimp_rgb_set_uchar (GimpRGB *rgb,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b);
|
||||
guchar red,
|
||||
guchar green,
|
||||
guchar blue);
|
||||
void gimp_rgb_get_uchar (const GimpRGB *rgb,
|
||||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b);
|
||||
guchar *red,
|
||||
guchar *green,
|
||||
guchar *blue);
|
||||
|
||||
void gimp_rgb_add (GimpRGB *rgb1,
|
||||
const GimpRGB *rgb2);
|
||||
|
@ -71,20 +71,20 @@ void gimp_rgb_composite (GimpRGB *color1,
|
|||
GimpRGBCompositeMode mode);
|
||||
|
||||
void gimp_rgba_set (GimpRGB *rgba,
|
||||
gdouble r,
|
||||
gdouble g,
|
||||
gdouble b,
|
||||
gdouble a);
|
||||
gdouble red,
|
||||
gdouble green,
|
||||
gdouble blue,
|
||||
gdouble alpha);
|
||||
void gimp_rgba_set_uchar (GimpRGB *rgba,
|
||||
guchar r,
|
||||
guchar g,
|
||||
guchar b,
|
||||
guchar a);
|
||||
guchar red,
|
||||
guchar green,
|
||||
guchar blue,
|
||||
guchar alpha);
|
||||
void gimp_rgba_get_uchar (const GimpRGB *rgba,
|
||||
guchar *r,
|
||||
guchar *g,
|
||||
guchar *b,
|
||||
guchar *a);
|
||||
guchar *red,
|
||||
guchar *green,
|
||||
guchar *blue,
|
||||
guchar *alpha);
|
||||
|
||||
void gimp_rgba_add (GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2);
|
||||
|
@ -92,7 +92,7 @@ void gimp_rgba_subtract (GimpRGB *rgba1,
|
|||
const GimpRGB *rgba2);
|
||||
void gimp_rgba_multiply (GimpRGB *rgba,
|
||||
gdouble factor);
|
||||
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
|
||||
gdouble gimp_rgba_distance (const GimpRGB *rgba1,
|
||||
const GimpRGB *rgba2);
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,7 @@ install : all
|
|||
OBJECTS = \
|
||||
gimpadaptivesupersample.obj \
|
||||
gimpbilinear.obj \
|
||||
gimpcmyk.obj \
|
||||
gimpcolorspace.obj \
|
||||
gimphsv.obj \
|
||||
gimprgb.obj
|
||||
|
|
Loading…
Reference in New Issue