mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
libgimpcolor, plugin: Remove gimp_rgb_luminance ()
This patch removes the two instances of gimp_rgb_luminance_uchar () and one instance of gimp_rgb_luminance () from the codebase. * plug-ins/common/checkerboard.c: Use gegl_color_get_pixel () to get the luminance value at the same time we're getting the RGBA value from the GeglColor. * plug-ins/gradient-flare/gradient-flare.c: Replace with GIMP_RGB_LUMINANCE () macro, which does not use GimpRGB.
This commit is contained in:
parent
fd091bc005
commit
b44687eb2f
5 changed files with 28 additions and 62 deletions
|
@ -82,8 +82,6 @@ EXPORTS
|
||||||
gimp_rgb_composite
|
gimp_rgb_composite
|
||||||
gimp_rgb_get_type
|
gimp_rgb_get_type
|
||||||
gimp_rgb_get_uchar
|
gimp_rgb_get_uchar
|
||||||
gimp_rgb_luminance
|
|
||||||
gimp_rgb_luminance_uchar
|
|
||||||
gimp_rgb_max
|
gimp_rgb_max
|
||||||
gimp_rgb_min
|
gimp_rgb_min
|
||||||
gimp_rgb_multiply
|
gimp_rgb_multiply
|
||||||
|
|
|
@ -197,42 +197,6 @@ gimp_rgb_clamp (GimpRGB *rgb)
|
||||||
rgb->a = CLAMP (rgb->a, 0.0, 1.0);
|
rgb->a = CLAMP (rgb->a, 0.0, 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_rgb_luminance:
|
|
||||||
* @rgb: a #GimpRGB struct
|
|
||||||
*
|
|
||||||
* Returns: the luminous intensity of the range from 0.0 to 1.0.
|
|
||||||
*
|
|
||||||
* Since: 2.4
|
|
||||||
**/
|
|
||||||
gdouble
|
|
||||||
gimp_rgb_luminance (const GimpRGB *rgb)
|
|
||||||
{
|
|
||||||
gdouble luminance;
|
|
||||||
|
|
||||||
g_return_val_if_fail (rgb != NULL, 0.0);
|
|
||||||
|
|
||||||
luminance = GIMP_RGB_LUMINANCE (rgb->r, rgb->g, rgb->b);
|
|
||||||
|
|
||||||
return CLAMP (luminance, 0.0, 1.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* gimp_rgb_luminance_uchar:
|
|
||||||
* @rgb: a #GimpRGB struct
|
|
||||||
*
|
|
||||||
* Returns: the luminous intensity in the range from 0 to 255.
|
|
||||||
*
|
|
||||||
* Since: 2.4
|
|
||||||
**/
|
|
||||||
guchar
|
|
||||||
gimp_rgb_luminance_uchar (const GimpRGB *rgb)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail (rgb != NULL, 0);
|
|
||||||
|
|
||||||
return ROUND (gimp_rgb_luminance (rgb) * 255.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_rgb_composite (GimpRGB *color1,
|
gimp_rgb_composite (GimpRGB *color1,
|
||||||
const GimpRGB *color2,
|
const GimpRGB *color2,
|
||||||
|
|
|
@ -78,9 +78,6 @@ gdouble gimp_rgb_max (const GimpRGB *rgb);
|
||||||
gdouble gimp_rgb_min (const GimpRGB *rgb);
|
gdouble gimp_rgb_min (const GimpRGB *rgb);
|
||||||
void gimp_rgb_clamp (GimpRGB *rgb);
|
void gimp_rgb_clamp (GimpRGB *rgb);
|
||||||
|
|
||||||
gdouble gimp_rgb_luminance (const GimpRGB *rgb);
|
|
||||||
guchar gimp_rgb_luminance_uchar (const GimpRGB *rgb);
|
|
||||||
|
|
||||||
void gimp_rgb_composite (GimpRGB *color1,
|
void gimp_rgb_composite (GimpRGB *color1,
|
||||||
const GimpRGB *color2,
|
const GimpRGB *color2,
|
||||||
GimpRGBCompositeMode mode);
|
GimpRGBCompositeMode mode);
|
||||||
|
|
|
@ -258,7 +258,10 @@ do_checkerboard_pattern (GObject *config,
|
||||||
{
|
{
|
||||||
CheckerboardParam_t param;
|
CheckerboardParam_t param;
|
||||||
GeglColor *color;
|
GeglColor *color;
|
||||||
GimpRGB fg, bg;
|
guchar fg[4] = {0, 0, 0, 0};
|
||||||
|
guchar bg[4] = {0, 0, 0, 0};
|
||||||
|
guchar fg_lum[1] = {0};
|
||||||
|
guchar bg_lum[1] = {0};
|
||||||
const Babl *format;
|
const Babl *format;
|
||||||
gint bpp;
|
gint bpp;
|
||||||
gboolean mode = FALSE;
|
gboolean mode = FALSE;
|
||||||
|
@ -271,38 +274,40 @@ do_checkerboard_pattern (GObject *config,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
color = gimp_context_get_background ();
|
color = gimp_context_get_background ();
|
||||||
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &bg);
|
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A u8", NULL), bg);
|
||||||
|
gegl_color_get_pixel (color, babl_format_with_space ("Y' u8", NULL), bg_lum);
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
color = gimp_context_get_foreground ();
|
color = gimp_context_get_foreground ();
|
||||||
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A double", NULL), &fg);
|
gegl_color_get_pixel (color, babl_format_with_space ("R'G'B'A u8", NULL), fg);
|
||||||
|
gegl_color_get_pixel (color, babl_format_with_space ("Y' u8", NULL), fg_lum);
|
||||||
g_object_unref (color);
|
g_object_unref (color);
|
||||||
|
|
||||||
if (gimp_drawable_is_gray (drawable))
|
if (gimp_drawable_is_gray (drawable))
|
||||||
{
|
{
|
||||||
param.bg[0] = gimp_rgb_luminance_uchar (&bg);
|
param.bg[0] = bg_lum[0];
|
||||||
gimp_rgba_get_uchar (&bg, NULL, NULL, NULL, param.bg + 1);
|
param.bg[1] = bg[3];
|
||||||
|
|
||||||
param.fg[0] = gimp_rgb_luminance_uchar (&fg);
|
param.fg[0] = fg_lum[0];
|
||||||
gimp_rgba_get_uchar (&fg, NULL, NULL, NULL, param.fg + 3);
|
param.fg[1] = fg[3];
|
||||||
|
|
||||||
if (gimp_drawable_has_alpha (drawable))
|
|
||||||
format = babl_format ("R'G'B'A u8");
|
|
||||||
else
|
|
||||||
format = babl_format ("R'G'B' u8");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
gimp_rgba_get_uchar (&bg,
|
|
||||||
param.bg, param.bg + 1, param.bg + 2, param.bg + 1);
|
|
||||||
|
|
||||||
gimp_rgba_get_uchar (&fg,
|
|
||||||
param.fg, param.fg + 1, param.fg + 2, param.fg + 3);
|
|
||||||
|
|
||||||
if (gimp_drawable_has_alpha (drawable))
|
if (gimp_drawable_has_alpha (drawable))
|
||||||
format = babl_format ("Y'A u8");
|
format = babl_format ("Y'A u8");
|
||||||
else
|
else
|
||||||
format = babl_format ("Y' u8");
|
format = babl_format ("Y' u8");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
for (gint i = 0; i < 4; i++)
|
||||||
|
{
|
||||||
|
param.bg[i] = bg[i];
|
||||||
|
param.fg[i] = fg[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gimp_drawable_has_alpha (drawable))
|
||||||
|
format = babl_format ("R'G'B'A u8");
|
||||||
|
else
|
||||||
|
format = babl_format ("R'G'B' u8");
|
||||||
|
}
|
||||||
|
|
||||||
bpp = babl_format_get_bytes_per_pixel (format);
|
bpp = babl_format_get_bytes_per_pixel (format);
|
||||||
|
|
||||||
|
|
|
@ -1258,7 +1258,9 @@ plugin_put_pixel_func (gint ix,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dest[0] = gimp_rgb_luminance_uchar (color);
|
guchar rgb[3] = {color->r * 255, color->g * 255, color->b * 255};
|
||||||
|
|
||||||
|
dest[0] = GIMP_RGB_LUMINANCE (rgb[0], rgb[1], rgb[2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dinfo.has_alpha)
|
if (dinfo.has_alpha)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue