mirror of https://github.com/GNOME/gimp.git
libgimpcolor, plug-ins: Remove GimpHSV
This patch replaces all instances of GimpHSV in the codebase with babl implementations, so that it can removed as part of the color space invasion.
This commit is contained in:
parent
99403fe5a3
commit
c36b7d016f
|
@ -69,11 +69,6 @@ EXPORTS
|
||||||
gimp_hsl_set
|
gimp_hsl_set
|
||||||
gimp_hsl_set_alpha
|
gimp_hsl_set_alpha
|
||||||
gimp_hsl_to_rgb
|
gimp_hsl_to_rgb
|
||||||
gimp_hsv_clamp
|
|
||||||
gimp_hsv_get_type
|
|
||||||
gimp_hsv_set
|
|
||||||
gimp_hsv_to_rgb
|
|
||||||
gimp_hsva_set
|
|
||||||
gimp_param_color_get_type
|
gimp_param_color_get_type
|
||||||
gimp_param_spec_color
|
gimp_param_spec_color
|
||||||
gimp_param_spec_color_from_string
|
gimp_param_spec_color_from_string
|
||||||
|
@ -96,7 +91,6 @@ EXPORTS
|
||||||
gimp_rgb_set_alpha
|
gimp_rgb_set_alpha
|
||||||
gimp_rgb_set_uchar
|
gimp_rgb_set_uchar
|
||||||
gimp_rgb_to_hsl
|
gimp_rgb_to_hsl
|
||||||
gimp_rgb_to_hsv
|
|
||||||
gimp_rgba_add
|
gimp_rgba_add
|
||||||
gimp_rgba_distance
|
gimp_rgba_distance
|
||||||
gimp_rgba_get_uchar
|
gimp_rgba_get_uchar
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include <libgimpcolor/gimpcolorspace.h>
|
#include <libgimpcolor/gimpcolorspace.h>
|
||||||
#include <libgimpcolor/gimpcolortransform.h>
|
#include <libgimpcolor/gimpcolortransform.h>
|
||||||
#include <libgimpcolor/gimphsl.h>
|
#include <libgimpcolor/gimphsl.h>
|
||||||
#include <libgimpcolor/gimphsv.h>
|
|
||||||
#include <libgimpcolor/gimppixbuf.h>
|
#include <libgimpcolor/gimppixbuf.h>
|
||||||
#include <libgimpcolor/gimprgb.h>
|
#include <libgimpcolor/gimprgb.h>
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
|
|
||||||
#include "gimpcolorspace.h"
|
#include "gimpcolorspace.h"
|
||||||
#include "gimprgb.h"
|
#include "gimprgb.h"
|
||||||
#include "gimphsv.h"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,138 +49,6 @@
|
||||||
/* GimpRGB functions */
|
/* GimpRGB functions */
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_rgb_to_hsv:
|
|
||||||
* @rgb: A color value in the RGB colorspace
|
|
||||||
* @hsv: (out caller-allocates): The value converted to the HSV colorspace
|
|
||||||
*
|
|
||||||
* Does a conversion from RGB to HSV (Hue, Saturation,
|
|
||||||
* Value) colorspace.
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
gimp_rgb_to_hsv (const GimpRGB *rgb,
|
|
||||||
GimpHSV *hsv)
|
|
||||||
{
|
|
||||||
gdouble max, min, delta;
|
|
||||||
|
|
||||||
g_return_if_fail (rgb != NULL);
|
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
max = gimp_rgb_max (rgb);
|
|
||||||
min = gimp_rgb_min (rgb);
|
|
||||||
|
|
||||||
hsv->v = max;
|
|
||||||
delta = max - min;
|
|
||||||
|
|
||||||
if (delta > 0.0001)
|
|
||||||
{
|
|
||||||
hsv->s = delta / max;
|
|
||||||
|
|
||||||
if (rgb->r == max)
|
|
||||||
{
|
|
||||||
hsv->h = (rgb->g - rgb->b) / delta;
|
|
||||||
if (hsv->h < 0.0)
|
|
||||||
hsv->h += 6.0;
|
|
||||||
}
|
|
||||||
else if (rgb->g == max)
|
|
||||||
{
|
|
||||||
hsv->h = 2.0 + (rgb->b - rgb->r) / delta;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hsv->h = 4.0 + (rgb->r - rgb->g) / delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
hsv->h /= 6.0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hsv->s = 0.0;
|
|
||||||
hsv->h = 0.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
hsv->a = rgb->a;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_hsv_to_rgb:
|
|
||||||
* @hsv: A color value in the HSV colorspace
|
|
||||||
* @rgb: (out caller-allocates): The returned RGB value.
|
|
||||||
*
|
|
||||||
* Converts a color value from HSV to RGB colorspace
|
|
||||||
**/
|
|
||||||
void
|
|
||||||
gimp_hsv_to_rgb (const GimpHSV *hsv,
|
|
||||||
GimpRGB *rgb)
|
|
||||||
{
|
|
||||||
gint i;
|
|
||||||
gdouble f, w, q, t;
|
|
||||||
|
|
||||||
gdouble hue;
|
|
||||||
|
|
||||||
g_return_if_fail (rgb != NULL);
|
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
if (hsv->s == 0.0)
|
|
||||||
{
|
|
||||||
rgb->r = hsv->v;
|
|
||||||
rgb->g = hsv->v;
|
|
||||||
rgb->b = hsv->v;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
hue = hsv->h;
|
|
||||||
|
|
||||||
if (hue == 1.0)
|
|
||||||
hue = 0.0;
|
|
||||||
|
|
||||||
hue *= 6.0;
|
|
||||||
|
|
||||||
i = (gint) hue;
|
|
||||||
f = hue - i;
|
|
||||||
w = hsv->v * (1.0 - hsv->s);
|
|
||||||
q = hsv->v * (1.0 - (hsv->s * f));
|
|
||||||
t = hsv->v * (1.0 - (hsv->s * (1.0 - f)));
|
|
||||||
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
rgb->r = hsv->v;
|
|
||||||
rgb->g = t;
|
|
||||||
rgb->b = w;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
rgb->r = q;
|
|
||||||
rgb->g = hsv->v;
|
|
||||||
rgb->b = w;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
rgb->r = w;
|
|
||||||
rgb->g = hsv->v;
|
|
||||||
rgb->b = t;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
rgb->r = w;
|
|
||||||
rgb->g = q;
|
|
||||||
rgb->b = hsv->v;
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
rgb->r = t;
|
|
||||||
rgb->g = w;
|
|
||||||
rgb->b = hsv->v;
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
rgb->r = hsv->v;
|
|
||||||
rgb->g = w;
|
|
||||||
rgb->b = q;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rgb->a = hsv->a;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gimp_rgb_to_hsl:
|
* gimp_rgb_to_hsl:
|
||||||
* @rgb: A color value in the RGB colorspace
|
* @rgb: A color value in the RGB colorspace
|
||||||
|
|
|
@ -33,13 +33,9 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
/* GimpRGB function */
|
/* GimpRGB function */
|
||||||
|
|
||||||
void gimp_rgb_to_hsv (const GimpRGB *rgb,
|
|
||||||
GimpHSV *hsv);
|
|
||||||
void gimp_rgb_to_hsl (const GimpRGB *rgb,
|
void gimp_rgb_to_hsl (const GimpRGB *rgb,
|
||||||
GimpHSL *hsl);
|
GimpHSL *hsl);
|
||||||
|
|
||||||
void gimp_hsv_to_rgb (const GimpHSV *hsv,
|
|
||||||
GimpRGB *rgb);
|
|
||||||
void gimp_hsl_to_rgb (const GimpHSL *hsl,
|
void gimp_hsl_to_rgb (const GimpHSL *hsl,
|
||||||
GimpRGB *rgb);
|
GimpRGB *rgb);
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ typedef struct _GimpParamSpecColor GimpParamSpecColor;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
typedef struct _GimpRGB GimpRGB;
|
typedef struct _GimpRGB GimpRGB;
|
||||||
typedef struct _GimpHSV GimpHSV;
|
|
||||||
typedef struct _GimpHSL GimpHSL;
|
typedef struct _GimpHSL GimpHSL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -58,21 +57,6 @@ struct _GimpRGB
|
||||||
gdouble r, g, b, a;
|
gdouble r, g, b, a;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* GimpHSV:
|
|
||||||
* @h: the hue component
|
|
||||||
* @s: the saturation component
|
|
||||||
* @v: the value component
|
|
||||||
* @a: the alpha component
|
|
||||||
*
|
|
||||||
* Used to keep HSV and HSVA colors. All components are in a range of
|
|
||||||
* [0.0..1.0].
|
|
||||||
**/
|
|
||||||
struct _GimpHSV
|
|
||||||
{
|
|
||||||
gdouble h, s, v, a;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GimpHSL:
|
* GimpHSL:
|
||||||
* @h: the hue component
|
* @h: the hue component
|
||||||
|
|
|
@ -1,96 +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 "gimpcolortypes.h"
|
|
||||||
|
|
||||||
#include "gimphsv.h"
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* SECTION: gimphsv
|
|
||||||
* @title: GimpHSV
|
|
||||||
* @short_description: Definitions and Functions relating to HSV colors.
|
|
||||||
*
|
|
||||||
* Definitions and Functions relating to HSV colors.
|
|
||||||
**/
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GIMP_TYPE_HSV
|
|
||||||
*/
|
|
||||||
|
|
||||||
static GimpHSV * gimp_hsv_copy (const GimpHSV *hsv);
|
|
||||||
|
|
||||||
|
|
||||||
G_DEFINE_BOXED_TYPE (GimpHSV, gimp_hsv, gimp_hsv_copy, g_free)
|
|
||||||
|
|
||||||
static GimpHSV *
|
|
||||||
gimp_hsv_copy (const GimpHSV *hsv)
|
|
||||||
{
|
|
||||||
return g_memdup2 (hsv, sizeof (GimpHSV));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/* HSV functions */
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_hsv_set (GimpHSV *hsv,
|
|
||||||
gdouble h,
|
|
||||||
gdouble s,
|
|
||||||
gdouble v)
|
|
||||||
{
|
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
hsv->h = h;
|
|
||||||
hsv->s = s;
|
|
||||||
hsv->v = v;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_hsv_clamp (GimpHSV *hsv)
|
|
||||||
{
|
|
||||||
g_return_if_fail (hsv != NULL);
|
|
||||||
|
|
||||||
hsv->h -= (gint) hsv->h;
|
|
||||||
|
|
||||||
if (hsv->h < 0)
|
|
||||||
hsv->h += 1.0;
|
|
||||||
|
|
||||||
hsv->s = CLAMP (hsv->s, 0.0, 1.0);
|
|
||||||
hsv->v = CLAMP (hsv->v, 0.0, 1.0);
|
|
||||||
hsv->a = CLAMP (hsv->a, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
|
||||||
gimp_hsva_set (GimpHSV *hsva,
|
|
||||||
gdouble h,
|
|
||||||
gdouble s,
|
|
||||||
gdouble v,
|
|
||||||
gdouble a)
|
|
||||||
{
|
|
||||||
g_return_if_fail (hsva != NULL);
|
|
||||||
|
|
||||||
hsva->h = h;
|
|
||||||
hsva->s = s;
|
|
||||||
hsva->v = v;
|
|
||||||
hsva->a = a;
|
|
||||||
}
|
|
|
@ -1,54 +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_HSV_H__
|
|
||||||
#define __GIMP_HSV_H__
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
|
||||||
|
|
||||||
/* For information look into the C source or the html documentation */
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* GIMP_TYPE_HSV
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define GIMP_TYPE_HSV (gimp_hsv_get_type ())
|
|
||||||
|
|
||||||
GType gimp_hsv_get_type (void) G_GNUC_CONST;
|
|
||||||
|
|
||||||
void gimp_hsv_set (GimpHSV *hsv,
|
|
||||||
gdouble hue,
|
|
||||||
gdouble saturation,
|
|
||||||
gdouble value);
|
|
||||||
void gimp_hsv_clamp (GimpHSV *hsv);
|
|
||||||
|
|
||||||
void gimp_hsva_set (GimpHSV *hsva,
|
|
||||||
gdouble hue,
|
|
||||||
gdouble saturation,
|
|
||||||
gdouble value,
|
|
||||||
gdouble alpha);
|
|
||||||
|
|
||||||
|
|
||||||
G_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __GIMP_HSV_H__ */
|
|
|
@ -9,7 +9,6 @@ libgimpcolor_sources = files(
|
||||||
'gimpcolorspace.c',
|
'gimpcolorspace.c',
|
||||||
'gimpcolortransform.c',
|
'gimpcolortransform.c',
|
||||||
'gimphsl.c',
|
'gimphsl.c',
|
||||||
'gimphsv.c',
|
|
||||||
'gimppixbuf.c',
|
'gimppixbuf.c',
|
||||||
'gimprgb.c',
|
'gimprgb.c',
|
||||||
)
|
)
|
||||||
|
@ -24,7 +23,6 @@ libgimpcolor_headers_introspectable = files(
|
||||||
'gimpcolorspace.h',
|
'gimpcolorspace.h',
|
||||||
'gimpcolortransform.h',
|
'gimpcolortransform.h',
|
||||||
'gimphsl.h',
|
'gimphsl.h',
|
||||||
'gimphsv.h',
|
|
||||||
'gimppixbuf.h',
|
'gimppixbuf.h',
|
||||||
'gimprgb.h',
|
'gimprgb.h',
|
||||||
|
|
||||||
|
|
|
@ -661,6 +661,8 @@ CML_main_function (gboolean preview_p)
|
||||||
GeglBuffer *dest_buffer;
|
GeglBuffer *dest_buffer;
|
||||||
const Babl *src_format;
|
const Babl *src_format;
|
||||||
const Babl *dest_format;
|
const Babl *dest_format;
|
||||||
|
const Babl *to_hsv;
|
||||||
|
const Babl *to_rgb;
|
||||||
guchar *dest_buf = NULL;
|
guchar *dest_buf = NULL;
|
||||||
guchar *src_buf = NULL;
|
guchar *src_buf = NULL;
|
||||||
gint x, y;
|
gint x, y;
|
||||||
|
@ -684,6 +686,9 @@ CML_main_function (gboolean preview_p)
|
||||||
&width_by_pixel, &height_by_pixel))
|
&width_by_pixel, &height_by_pixel))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
|
to_hsv = babl_fish (babl_format ("R'G'B' float"), babl_format ("HSV float"));
|
||||||
|
to_rgb = babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float"));
|
||||||
|
|
||||||
src_has_alpha = dest_has_alpha = gimp_drawable_has_alpha (drawable);
|
src_has_alpha = dest_has_alpha = gimp_drawable_has_alpha (drawable);
|
||||||
src_is_gray = dest_is_gray = gimp_drawable_is_gray (drawable);
|
src_is_gray = dest_is_gray = gimp_drawable_is_gray (drawable);
|
||||||
|
|
||||||
|
@ -941,19 +946,14 @@ CML_main_function (gboolean preview_p)
|
||||||
|
|
||||||
if (! dest_is_gray)
|
if (! dest_is_gray)
|
||||||
{
|
{
|
||||||
GimpHSV hsv;
|
gfloat hsv[3] = { h / 255.0, s / 255.0, v / 255.0 };
|
||||||
GimpRGB rgb;
|
gfloat rgb[3];
|
||||||
|
|
||||||
gimp_hsv_set (&hsv,
|
babl_process (to_rgb, hsv, rgb, 1);
|
||||||
(gdouble) h / 255.0,
|
|
||||||
(gdouble) s / 255.0,
|
|
||||||
(gdouble) v / 255.0);
|
|
||||||
|
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
r = ROUND (rgb[0] * 255.0);
|
||||||
|
g = ROUND (rgb[1] * 255.0);
|
||||||
r = ROUND (rgb.r * 255.0);
|
b = ROUND (rgb[2] * 255.0);
|
||||||
g = ROUND (rgb.g * 255.0);
|
|
||||||
b = ROUND (rgb.b * 255.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* render destination */
|
/* render destination */
|
||||||
|
@ -980,29 +980,28 @@ CML_main_function (gboolean preview_p)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
gfloat rgb[3];
|
||||||
GimpHSV hsv;
|
gfloat hsv[3];
|
||||||
|
|
||||||
rgb.r = (gdouble) rgbi[0] / 255.0;
|
for (i = 0; i < 3; i++)
|
||||||
rgb.g = (gdouble) rgbi[1] / 255.0;
|
rgb[i] = (gfloat) rgbi[i] / 255.0;
|
||||||
rgb.b = (gdouble) rgbi[2] / 255.0;
|
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
babl_process (to_hsv, rgb, hsv, 1);
|
||||||
|
|
||||||
if (VALS.hue.function != CML_KEEP_VALUES)
|
if (VALS.hue.function != CML_KEEP_VALUES)
|
||||||
hsv.h = (gdouble) h / 255.0;
|
hsv[0] = (gfloat) h / 255.0;
|
||||||
|
|
||||||
if (VALS.sat.function != CML_KEEP_VALUES)
|
if (VALS.sat.function != CML_KEEP_VALUES)
|
||||||
hsv.s = (gdouble) s / 255.0;
|
hsv[1] = (gfloat) s / 255.0;
|
||||||
|
|
||||||
if (VALS.val.function != CML_KEEP_VALUES)
|
if (VALS.val.function != CML_KEEP_VALUES)
|
||||||
hsv.v = (gdouble) v / 255.0;
|
hsv[2] = (gfloat) v / 255.0;
|
||||||
|
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
babl_process (to_rgb, hsv, rgb, 1);
|
||||||
|
|
||||||
r = ROUND (rgb.r * 255.0);
|
r = ROUND (rgb[0] * 255.0);
|
||||||
g = ROUND (rgb.g * 255.0);
|
g = ROUND (rgb[1] * 255.0);
|
||||||
b = ROUND (rgb.b * 255.0);
|
b = ROUND (rgb[2] * 255.0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1935,10 +1934,13 @@ function_graph_draw (GtkWidget *widget,
|
||||||
{
|
{
|
||||||
gint x, y;
|
gint x, y;
|
||||||
gint rgbi[3];
|
gint rgbi[3];
|
||||||
GimpHSV hsv;
|
gfloat hsv[3];
|
||||||
GimpRGB rgb;
|
gfloat rgb[3];
|
||||||
gint channel_id = GPOINTER_TO_INT (data[0]);
|
gint channel_id = GPOINTER_TO_INT (data[0]);
|
||||||
CML_PARAM *param = data[1];
|
CML_PARAM *param = data[1];
|
||||||
|
const Babl *fish;
|
||||||
|
|
||||||
|
fish = babl_fish (babl_format ("HSV float"), babl_format ("R'G'B' float"));
|
||||||
|
|
||||||
cairo_set_line_width (cr, 1.0);
|
cairo_set_line_width (cr, 1.0);
|
||||||
|
|
||||||
|
@ -1951,18 +1953,18 @@ function_graph_draw (GtkWidget *widget,
|
||||||
if ((0 <= channel_id) && (channel_id <= 2))
|
if ((0 <= channel_id) && (channel_id <= 2))
|
||||||
rgbi[channel_id] = CANNONIZE ((*param), ((gdouble) x / (gdouble) 255));
|
rgbi[channel_id] = CANNONIZE ((*param), ((gdouble) x / (gdouble) 255));
|
||||||
|
|
||||||
hsv.h = (gdouble) rgbi[0] / 255.0;
|
hsv[0] = (gdouble) rgbi[0] / 255.0;
|
||||||
hsv.s = (gdouble) rgbi[1] / 255.0;
|
hsv[1] = (gdouble) rgbi[1] / 255.0;
|
||||||
hsv.v = (gdouble) rgbi[2] / 255.0;
|
hsv[2] = (gdouble) rgbi[2] / 255.0;
|
||||||
|
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
babl_process (fish, hsv, rgb, 1);
|
||||||
|
|
||||||
for (y = 0; y < GRAPHSIZE; y++)
|
for (y = 0; y < GRAPHSIZE; y++)
|
||||||
{
|
{
|
||||||
GIMP_CAIRO_RGB24_SET_PIXEL((img+(y*img_stride+x*4)),
|
GIMP_CAIRO_RGB24_SET_PIXEL((img+(y*img_stride+x*4)),
|
||||||
ROUND (rgb.r * 255.0),
|
ROUND (rgb[0] * 255.0),
|
||||||
ROUND (rgb.g * 255.0),
|
ROUND (rgb[1] * 255.0),
|
||||||
ROUND (rgb.b * 255.0));
|
ROUND (rgb[2] * 255.0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1962,6 +1962,8 @@ calc_sample_one_gradient (void)
|
||||||
guchar *gradient;
|
guchar *gradient;
|
||||||
gdouble hue_deg;
|
gdouble hue_deg;
|
||||||
gint i, j, hue;
|
gint i, j, hue;
|
||||||
|
const Babl *to_hsv = babl_fish ("R'G'B'A u8", "HSVA float");
|
||||||
|
const Babl *to_rgb = babl_fish ("HSVA float", "R'G'B'A u8");
|
||||||
|
|
||||||
for (i = 0; i < G_N_ELEMENTS (table); i++)
|
for (i = 0; i < G_N_ELEMENTS (table); i++)
|
||||||
{
|
{
|
||||||
|
@ -1986,27 +1988,22 @@ calc_sample_one_gradient (void)
|
||||||
|
|
||||||
if (hue > 0)
|
if (hue > 0)
|
||||||
{
|
{
|
||||||
|
gfloat *hsva;
|
||||||
|
|
||||||
|
hsva = g_new0 (gfloat, sizeof (gfloat) * (GRADIENT_RESOLUTION * 4));
|
||||||
|
babl_process (to_hsv, gradient, hsva, GRADIENT_RESOLUTION);
|
||||||
|
|
||||||
for (j = 0; j < GRADIENT_RESOLUTION; j++)
|
for (j = 0; j < GRADIENT_RESOLUTION; j++)
|
||||||
{
|
{
|
||||||
GimpRGB rgb;
|
hsva[j * 4] = (hsva[j * 4] + ((gdouble) hue / 255.0));
|
||||||
GimpHSV hsv;
|
|
||||||
|
|
||||||
rgb.r = (gdouble) gradient[j*4] / 255.0;
|
if (hsva[j * 4] > 1.0)
|
||||||
rgb.g = (gdouble) gradient[j*4+1] / 255.0;
|
hsva[j * 4] -= 1.0;
|
||||||
rgb.b = (gdouble) gradient[j*4+2] / 255.0;
|
|
||||||
|
|
||||||
gimp_rgb_to_hsv (&rgb, &hsv);
|
|
||||||
|
|
||||||
hsv.h = (hsv.h + ((gdouble) hue / 255.0));
|
|
||||||
if (hsv.h > 1.0)
|
|
||||||
hsv.h -= 1.0;
|
|
||||||
|
|
||||||
gimp_hsv_to_rgb (&hsv, &rgb);
|
|
||||||
|
|
||||||
gradient[j*4] = ROUND (rgb.r * 255.0);
|
|
||||||
gradient[j*4+1] = ROUND (rgb.g * 255.0);
|
|
||||||
gradient[j*4+2] = ROUND (rgb.b * 255.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
babl_process (to_rgb, hsva, gradient, GRADIENT_RESOLUTION);
|
||||||
|
|
||||||
|
g_free (hsva);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue