libgimpcolor: Remove GimpCMYK code

Part of the color space invasion API
updates. CMYK conversion should be
done through babl/GEGL now.
This commit is contained in:
Alx Sa 2024-06-21 16:00:18 +00:00
parent 04a9771c9c
commit 3842efd524
8 changed files with 0 additions and 428 deletions

View File

@ -1,223 +0,0 @@
/* 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 3 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, see
* <https://www.gnu.org/licenses/>.
*/
#include "config.h"
#include <glib-object.h>
#include "libgimpmath/gimpmath.h"
#include "gimpcolortypes.h"
#include "gimpcmyk.h"
/**
* SECTION: gimpcmyk
* @title: GimpCMYK
* @short_description: Definitions and Functions relating to CMYK colors.
*
* Definitions and Functions relating to CMYK colors.
**/
/*
* GIMP_TYPE_CMYK
*/
static GimpCMYK * gimp_cmyk_copy (const GimpCMYK *cmyk);
G_DEFINE_BOXED_TYPE (GimpCMYK, gimp_cmyk, gimp_cmyk_copy, g_free)
static GimpCMYK *
gimp_cmyk_copy (const GimpCMYK *cmyk)
{
return g_memdup2 (cmyk, sizeof (GimpCMYK));
}
/* CMYK functions */
/**
* gimp_cmyk_set:
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
* @cyan: The Cyan channel of the CMYK value
* @magenta: The Magenta channel
* @yellow: The Yellow channel
* @black: The blacK channel
*
* Very basic initialiser for the internal #GimpCMYK structure. Channel
* values are doubles in the range 0 to 1.
**/
void
gimp_cmyk_set (GimpCMYK *cmyk,
gdouble cyan,
gdouble magenta,
gdouble yellow,
gdouble black)
{
g_return_if_fail (cmyk != NULL);
cmyk->c = cyan;
cmyk->m = magenta;
cmyk->y = yellow;
cmyk->k = black;
}
/**
* gimp_cmyk_set_uchar:
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
* @cyan: The Cyan channel of the CMYK value
* @magenta: The Magenta channel
* @yellow: The Yellow channel
* @black: The blacK channel
*
* The same as gimp_cmyk_set(), except that channel values are
* unsigned chars in the range 0 to 255.
**/
void
gimp_cmyk_set_uchar (GimpCMYK *cmyk,
guchar cyan,
guchar magenta,
guchar yellow,
guchar black)
{
g_return_if_fail (cmyk != NULL);
cmyk->c = (gdouble) cyan / 255.0;
cmyk->m = (gdouble) magenta / 255.0;
cmyk->y = (gdouble) yellow / 255.0;
cmyk->k = (gdouble) black / 255.0;
}
/**
* gimp_cmyk_get_uchar:
* @cmyk: A #GimpCMYK structure which will hold the specified CMYK value.
* @cyan: (out) (optional): The Cyan channel of the CMYK value
* @magenta: (out) (optional): The Magenta channel
* @yellow: (out) (optional): The Yellow channel
* @black: (out) (optional): The blacK channel
*
* Retrieve individual channel values from a #GimpCMYK structure. Channel
* values are pointers to unsigned chars in the range 0 to 255.
**/
void
gimp_cmyk_get_uchar (const GimpCMYK *cmyk,
guchar *cyan,
guchar *magenta,
guchar *yellow,
guchar *black)
{
g_return_if_fail (cmyk != NULL);
if (cyan) *cyan = ROUND (CLAMP (cmyk->c, 0.0, 1.0) * 255.0);
if (magenta) *magenta = ROUND (CLAMP (cmyk->m, 0.0, 1.0) * 255.0);
if (yellow) *yellow = ROUND (CLAMP (cmyk->y, 0.0, 1.0) * 255.0);
if (black) *black = ROUND (CLAMP (cmyk->k, 0.0, 1.0) * 255.0);
}
/* CMYKA functions */
/**
* gimp_cmyka_set:
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
* @cyan: The Cyan channel of the CMYK value
* @magenta: The Magenta channel
* @yellow: The Yellow channel
* @black: The blacK channel
* @alpha: The Alpha channel
*
* Initialiser for the internal #GimpCMYK structure. Channel values are
* doubles in the range 0 to 1.
**/
void
gimp_cmyka_set (GimpCMYK *cmyka,
gdouble cyan,
gdouble magenta,
gdouble yellow,
gdouble black,
gdouble alpha)
{
g_return_if_fail (cmyka != NULL);
cmyka->c = cyan;
cmyka->m = magenta;
cmyka->y = yellow;
cmyka->k = black;
cmyka->a = alpha;
}
/**
* gimp_cmyka_set_uchar:
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
* @cyan: The Cyan channel of the CMYK value
* @magenta: The Magenta channel
* @yellow: The Yellow channel
* @black: The blacK channel
* @alpha: The Alpha channel
*
* The same as gimp_cmyka_set(), except that channel values are
* unsigned chars in the range 0 to 255.
**/
void
gimp_cmyka_set_uchar (GimpCMYK *cmyka,
guchar cyan,
guchar magenta,
guchar yellow,
guchar black,
guchar alpha)
{
g_return_if_fail (cmyka != NULL);
cmyka->c = (gdouble) cyan / 255.0;
cmyka->m = (gdouble) magenta / 255.0;
cmyka->y = (gdouble) yellow / 255.0;
cmyka->k = (gdouble) black / 255.0;
cmyka->a = (gdouble) alpha / 255.0;
}
/**
* gimp_cmyka_get_uchar:
* @cmyka: A #GimpCMYK structure which will hold the specified CMYKA value.
* @cyan: (out) (optional): The Cyan channel of the CMYK value
* @magenta: (out) (optional): The Magenta channel
* @yellow: (out) (optional): The Yellow channel
* @black: (out) (optional): The blacK channel
* @alpha: (out) (optional): The Alpha channel
*
* Retrieve individual channel values from a #GimpCMYK structure.
* Channel values are pointers to unsigned chars in the range 0 to 255.
**/
void
gimp_cmyka_get_uchar (const GimpCMYK *cmyka,
guchar *cyan,
guchar *magenta,
guchar *yellow,
guchar *black,
guchar *alpha)
{
g_return_if_fail (cmyka != NULL);
if (cyan) *cyan = ROUND (CLAMP (cmyka->c, 0.0, 1.0) * 255.0);
if (magenta) *magenta = ROUND (CLAMP (cmyka->m, 0.0, 1.0) * 255.0);
if (yellow) *yellow = ROUND (CLAMP (cmyka->y, 0.0, 1.0) * 255.0);
if (black) *black = ROUND (CLAMP (cmyka->k, 0.0, 1.0) * 255.0);
if (alpha) *alpha = ROUND (CLAMP (cmyka->a, 0.0, 1.0) * 255.0);
}

View File

@ -1,78 +0,0 @@
/* 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 3 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, see
* <https://www.gnu.org/licenses/>.
*/
#if !defined (__GIMP_COLOR_H_INSIDE__) && !defined (GIMP_COLOR_COMPILATION)
#error "Only <libgimpcolor/gimpcolor.h> can be included directly."
#endif
#ifndef __GIMP_CMYK_H__
#define __GIMP_CMYK_H__
G_BEGIN_DECLS
/* For information look into the C source or the html documentation */
/*
* GIMP_TYPE_CMYK
*/
#define GIMP_TYPE_CMYK (gimp_cmyk_get_type ())
GType gimp_cmyk_get_type (void) G_GNUC_CONST;
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__ */

View File

@ -11,14 +11,6 @@ EXPORTS
gimp_cairo_set_source_rgba
gimp_cairo_surface_create_buffer
gimp_cairo_surface_get_format
gimp_cmyk_get_type
gimp_cmyk_get_uchar
gimp_cmyk_set
gimp_cmyk_set_uchar
gimp_cmyk_to_rgb
gimp_cmyka_get_uchar
gimp_cmyka_set
gimp_cmyka_set_uchar
gimp_color_is_out_of_gamut
gimp_color_is_out_of_self_gamut
gimp_color_is_perceptually_identical
@ -105,7 +97,6 @@ EXPORTS
gimp_rgb_set
gimp_rgb_set_alpha
gimp_rgb_set_uchar
gimp_rgb_to_cmyk
gimp_rgb_to_hsl
gimp_rgb_to_hsv
gimp_rgba_add

View File

@ -32,7 +32,6 @@
#include <libgimpcolor/gimpcolorprofile.h>
#include <libgimpcolor/gimpcolorspace.h>
#include <libgimpcolor/gimpcolortransform.h>
#include <libgimpcolor/gimpcmyk.h>
#include <libgimpcolor/gimphsl.h>
#include <libgimpcolor/gimphsv.h>
#include <libgimpcolor/gimppixbuf.h>

View File

@ -308,94 +308,3 @@ gimp_hsl_to_rgb (const GimpHSL *hsl,
rgb->a = hsl->a;
}
/**
* gimp_rgb_to_cmyk:
* @rgb: A value in the RGB colorspace
* @pullout: A scaling value (0-1) indicating how much black should be
* pulled out
* @cmyk: (out caller-allocates): The input value naively converted
* to the CMYK colorspace
*
* Does a naive conversion from RGB to CMYK colorspace. A simple
* formula that doesn't take any color-profiles into account is used.
* The amount of black pullout how can be controlled via the @pullout
* parameter. A @pullout value of 0 makes this a conversion to CMY.
* A value of 1 causes the maximum amount of black to be pulled out.
**/
void
gimp_rgb_to_cmyk (const GimpRGB *rgb,
gdouble pullout,
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;
k *= pullout;
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;
}
/**
* gimp_cmyk_to_rgb:
* @cmyk: A color value in the CMYK colorspace
* @rgb: (out caller-allocates): The value converted to the RGB colorspace
*
* Does a simple transformation from the CMYK colorspace to the RGB
* colorspace, without taking color profiles into account.
**/
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;
}

View File

@ -37,16 +37,11 @@ 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,
gdouble pullout,
GimpCMYK *cmyk);
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);
G_END_DECLS

View File

@ -42,7 +42,6 @@ typedef struct _GimpParamSpecColor GimpParamSpecColor;
typedef struct _GimpRGB GimpRGB;
typedef struct _GimpHSV GimpHSV;
typedef struct _GimpHSL GimpHSL;
typedef struct _GimpCMYK GimpCMYK;
/**
* GimpRGB:
@ -89,24 +88,6 @@ struct _GimpHSL
gdouble h, s, l, a;
};
/**
* GimpCMYK:
* @c: the cyan component
* @m: the magenta component
* @y: the yellow component
* @k: the black component
* @a: the alpha component
*
* Used to keep CMYK and CMYKA colors. All components are in a range
* of [0.0..1.0]. An alpha value is somewhat useless in the CMYK
* colorspace, but we keep one around anyway so color conversions
* going to CMYK and back can preserve alpha.
**/
struct _GimpCMYK
{
gdouble c, m, y, k, a;
};
G_END_DECLS

View File

@ -2,7 +2,6 @@ libgimpcolor_sources = files(
'gimpadaptivesupersample.c',
'gimpbilinear.c',
'gimpcairo.c',
'gimpcmyk.c',
'gimpcolor.c',
'gimpcolor-parse.c',
'gimpcolormanaged.c',
@ -20,7 +19,6 @@ libgimpcolor_headers_introspectable = files(
'gimpadaptivesupersample.h',
'gimpbilinear.h',
'gimpcairo.h',
'gimpcmyk.h',
'gimpcolormanaged.h',
'gimpcolorprofile.h',
'gimpcolorspace.h',