Commit 4f870bc1 authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

deprecated RGB intensity functions and definitions. These coefficients do

2005-08-03  Sven Neumann  <sven@gimp.org>

	* libgimpcolor/gimprgb.[ch]: deprecated RGB intensity functions
	and definitions. These coefficients do not accurately compute
	luminance for contemporary monitors. Instead the coefficients from
	the sRGB spec should be used which have now been added.

	* libgimpcolor/gimpcolor.def: updated.

	* libgimp/gimpdrawable.c
	* libgimp/gimppixelfetcher.c
	* app/base/colorize.c
	* app/base/levels.c
	* app/base/temp-buf.c
	* app/core/gimpdrawable-blend.c
	* app/core/gimpdrawable-convert.c
	* app/core/gimpdrawable-desaturate.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage.c
	* app/gui/splash.c
	* app/widgets/gimpgradienteditor.c
	* modules/colorsel_triangle.c
	* plug-ins/common/aa.c
	* plug-ins/common/bumpmap.c
	* plug-ins/common/colorify.c
	* plug-ins/common/despeckle.c
	* plug-ins/common/displace.c
	* plug-ins/common/engrave.c
	* plug-ins/common/gradmap.c
	* plug-ins/common/grid.c
	* plug-ins/common/mng.c
	* plug-ins/common/newsprint.c
	* plug-ins/common/png.c
	* plug-ins/common/whirlpinch.c
	* plug-ins/gflare/gflare.c
	* plug-ins/gfli/gfli.c
	* plug-ins/maze/handy.c
	* plug-ins/pagecurl/pagecurl.c: use gimp_rgb_luminance() and
	friends instead of the deprecated intensity functions.
parent 79d2bb6a
2005-08-03 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimprgb.[ch]: deprecated RGB intensity functions
and definitions. These coefficients do not accurately compute
luminance for contemporary monitors. Instead the coefficients from
the sRGB spec should be used which have now been added.
* libgimpcolor/gimpcolor.def: updated.
* libgimp/gimpdrawable.c
* libgimp/gimppixelfetcher.c
* app/base/colorize.c
* app/base/levels.c
* app/base/temp-buf.c
* app/core/gimpdrawable-blend.c
* app/core/gimpdrawable-convert.c
* app/core/gimpdrawable-desaturate.c
* app/core/gimpimage-convert.c
* app/core/gimpimage.c
* app/gui/splash.c
* app/widgets/gimpgradienteditor.c
* modules/colorsel_triangle.c
* plug-ins/common/aa.c
* plug-ins/common/bumpmap.c
* plug-ins/common/colorify.c
* plug-ins/common/despeckle.c
* plug-ins/common/displace.c
* plug-ins/common/engrave.c
* plug-ins/common/gradmap.c
* plug-ins/common/grid.c
* plug-ins/common/mng.c
* plug-ins/common/newsprint.c
* plug-ins/common/png.c
* plug-ins/common/whirlpinch.c
* plug-ins/gflare/gflare.c
* plug-ins/gfli/gfli.c
* plug-ins/maze/handy.c
* plug-ins/pagecurl/pagecurl.c: use gimp_rgb_luminance() and
friends instead of the deprecated intensity functions.
2005-08-03 Michael Natterer <mitch@gimp.org>
* libgimp/gimpprocbrowserdialog.[ch]: removed all parameters from
......
......@@ -42,9 +42,9 @@ colorize_init (Colorize *colorize)
for (i = 0; i < 256; i ++)
{
colorize->lum_red_lookup[i] = i * GIMP_RGB_INTENSITY_RED;
colorize->lum_green_lookup[i] = i * GIMP_RGB_INTENSITY_GREEN;
colorize->lum_blue_lookup[i] = i * GIMP_RGB_INTENSITY_BLUE;
colorize->lum_red_lookup[i] = i * GIMP_RGB_LUMINANCE_RED;
colorize->lum_green_lookup[i] = i * GIMP_RGB_LUMINANCE_GREEN;
colorize->lum_blue_lookup[i] = i * GIMP_RGB_LUMINANCE_BLUE;
}
}
......
......@@ -194,7 +194,7 @@ levels_adjust_by_colors (Levels *levels,
guchar lightness;
/* Calculate lightness value */
lightness = GIMP_RGB_INTENSITY (gray[0], gray[1], gray[2]);
lightness = GIMP_RGB_LUMINANCE (gray[0], gray[1], gray[2]);
input = levels_input_from_color (channel, gray);
......
......@@ -116,7 +116,7 @@ temp_buf_to_gray (TempBuf *src_buf,
g_return_if_fail (src_buf->bytes == 3);
while (num_pixels--)
{
pix = GIMP_RGB_INTENSITY (src[0], src[1], src[2]) + 0.5;
pix = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
src += 3;
......@@ -127,7 +127,7 @@ temp_buf_to_gray (TempBuf *src_buf,
g_return_if_fail (src_buf->bytes == 4);
while (num_pixels--)
{
pix = GIMP_RGB_INTENSITY (src[0], src[1], src[2]) + 0.5;
pix = GIMP_RGB_LUMINANCE (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
*dest++ = src[3]; /* alpha channel */
......
......@@ -820,7 +820,7 @@ gradient_put_pixel (gint x,
else
{
/* Convert to grayscale */
gdouble gray = gimp_rgb_intensity (color);
gdouble gray = gimp_rgb_luminance (color);
if (ppd->dither_rand)
{
......@@ -1078,7 +1078,7 @@ gradient_fill_single_region_gray (RenderBlendData *rbd,
gradient_render_pixel (x, y, &color, rbd);
*dest++ = gimp_rgb_intensity_uchar (&color);
*dest++ = gimp_rgb_luminance_uchar (&color);
*dest++ = ROUND (color.a * 255.0);
}
}
......@@ -1102,7 +1102,7 @@ gradient_fill_single_region_gray_dither (RenderBlendData *rbd,
gradient_render_pixel (x, y, &color, rbd);
gray = gimp_rgb_intensity (&color);
gray = gimp_rgb_luminance (&color);
*dest++ = gray * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
*dest++ = color.a * 255.0 + (gdouble) (i & 0xff) / 256.0;
......
......@@ -186,7 +186,7 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
d = dest;
for (col = 0; col < srcPR.w; col++)
{
val = GIMP_RGB_INTENSITY (s[RED_PIX],
val = GIMP_RGB_LUMINANCE (s[RED_PIX],
s[GREEN_PIX],
s[BLUE_PIX]) + 0.5;
*d++ = (guchar) val;
......@@ -217,7 +217,7 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
for (col = 0; col < srcPR.w; col++)
{
offset = *s++ * 3;
val = GIMP_RGB_INTENSITY (cmap[offset+0],
val = GIMP_RGB_LUMINANCE (cmap[offset+0],
cmap[offset+1],
cmap[offset+2]) + 0.5;
*d++ = (guchar) val;
......
......@@ -161,7 +161,7 @@ desaturate_region_luminosity (gpointer data,
for (j = 0; j < srcPR->w; j++)
{
gint luminosity = GIMP_RGB_INTENSITY (s[RED_PIX],
gint luminosity = GIMP_RGB_LUMINANCE (s[RED_PIX],
s[GREEN_PIX],
s[BLUE_PIX]) + 0.5;
......
......@@ -760,8 +760,8 @@ color_quicksort (const void *c1,
Color *color1 = (Color *)c1;
Color *color2 = (Color *)c2;
double v1 = GIMP_RGB_INTENSITY (color1->red, color1->green, color1->blue);
double v2 = GIMP_RGB_INTENSITY (color2->red, color2->green, color2->blue);
double v1 = GIMP_RGB_LUMINANCE (color1->red, color1->green, color1->blue);
double v2 = GIMP_RGB_LUMINANCE (color2->red, color2->green, color2->blue);
if (v1 < v2)
return -1;
......
......@@ -2064,7 +2064,7 @@ gimp_image_transform_color (const GimpImage *dest_gimage,
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
/* NTSC conversion */
*dest = GIMP_RGB_INTENSITY (src[RED_PIX],
*dest = GIMP_RGB_LUMINANCE (src[RED_PIX],
src[GREEN_PIX],
src[BLUE_PIX]) + 0.5;
break;
......
......@@ -370,7 +370,7 @@ splash_average_bottom (GtkWidget *widget,
gint width, height;
gint rowstride;
gint channels;
gint intensity;
gint luminance;
gint count;
guint sum[3] = { 0, 0, 0 };
......@@ -404,13 +404,13 @@ splash_average_bottom (GtkWidget *widget,
pixels += rowstride;
}
intensity = GIMP_RGB_INTENSITY (sum[0] / count,
luminance = GIMP_RGB_LUMINANCE (sum[0] / count,
sum[1] / count,
sum[2] / count);
intensity = CLAMP0255 (intensity > 127 ? intensity - 223 : intensity + 223);
luminance = CLAMP0255 (luminance > 127 ? luminance - 223 : luminance + 223);
color->red = color->green = color->blue = (intensity << 8 | intensity);
color->red = color->green = color->blue = (luminance << 8 | luminance);
return gdk_colormap_alloc_color (gtk_widget_get_colormap (widget),
color, FALSE, TRUE);
......
......@@ -942,14 +942,12 @@ view_set_hint (GimpGradientEditor *editor,
gimp_rgb_to_hsv (&rgb, &hsv);
str1 = g_strdup_printf (_("Position: %0.6f"), xpos);
str2 = g_strdup_printf (_("RGB (%0.3f, %0.3f, %0.3f)"),
rgb.r, rgb.g, rgb.b);
str3 = g_strdup_printf (_("HSV (%0.3f, %0.3f, %0.3f)"),
hsv.h * 360.0, hsv.s, hsv.v);
str4 = g_strdup_printf (_("Intensity: %0.3f Opacity: %0.3f"),
GIMP_RGB_INTENSITY (rgb.r, rgb.g, rgb.b), rgb.a);
str4 = g_strdup_printf (_("Luminance: %0.3f Opacity: %0.3f"),
GIMP_RGB_LUMINANCE (rgb.r, rgb.g, rgb.b), rgb.a);
gradient_editor_set_hint (editor, str1, str2, str3, str4);
......
2005-08-03 Sven Neumann <sven@gimp.org>
* libgimpcolor/libgimpcolor-sections.txt
* libgimpcolor/tmpl/gimprgb.sgml: added gimp_rgb_luminance() and
friends.
2005-07-22 Sven Neumann <sven@gimp.org>
* libgimpwidgets/libgimpwidgets-sections.txt
......
......@@ -63,6 +63,8 @@ gimp_rgb_max
gimp_rgb_min
gimp_rgb_clamp
gimp_rgb_gamma
gimp_rgb_luminance
gimp_rgb_luminance_uchar
gimp_rgb_intensity
gimp_rgb_intensity_uchar
gimp_rgb_composite
......@@ -74,6 +76,10 @@ gimp_rgba_add
gimp_rgba_subtract
gimp_rgba_multiply
gimp_rgba_distance
GIMP_RGB_LUMINANCE
GIMP_RGB_LUMINANCE_RED
GIMP_RGB_LUMINANCE_GREEN
GIMP_RGB_LUMINANCE_BLUE
GIMP_RGB_INTENSITY
GIMP_RGB_INTENSITY_RED
GIMP_RGB_INTENSITY_GREEN
......
......@@ -193,6 +193,24 @@ Definitions and Functions relating to RGB colors.
@gamma:
<!-- ##### FUNCTION gimp_rgb_luminance ##### -->
<para>
</para>
@rgb:
@Returns:
<!-- ##### FUNCTION gimp_rgb_luminance_uchar ##### -->
<para>
</para>
@rgb:
@Returns:
<!-- ##### FUNCTION gimp_rgb_intensity ##### -->
<para>
......@@ -305,6 +323,37 @@ Definitions and Functions relating to RGB colors.
@Returns:
<!-- ##### MACRO GIMP_RGB_LUMINANCE ##### -->
<para>
</para>
@r:
@g:
@b:
<!-- ##### MACRO GIMP_RGB_LUMINANCE_RED ##### -->
<para>
</para>
<!-- ##### MACRO GIMP_RGB_LUMINANCE_GREEN ##### -->
<para>
</para>
<!-- ##### MACRO GIMP_RGB_LUMINANCE_BLUE ##### -->
<para>
</para>
<!-- ##### MACRO GIMP_RGB_INTENSITY ##### -->
<para>
This macro calculates the intensity of an RGB value based on
......
......@@ -248,12 +248,12 @@ gimp_drawable_get_color_uchar (gint32 drawable_ID,
break;
case GIMP_GRAY_IMAGE:
color_uchar[0] = gimp_rgb_intensity_uchar (color);
color_uchar[0] = gimp_rgb_luminance_uchar (color);
color_uchar[1] = 255;
break;
case GIMP_GRAYA_IMAGE:
color_uchar[0] = gimp_rgb_intensity_uchar (color);
color_uchar[0] = gimp_rgb_luminance_uchar (color);
gimp_rgba_get_uchar (color, NULL, NULL, NULL, &color_uchar[1]);
break;
......
......@@ -160,7 +160,7 @@ gimp_pixel_fetcher_set_bg_color (GimpPixelFetcher *pf,
{
case 2: pf->bg_color[1] = 255;
case 1:
pf->bg_color[0] = gimp_rgb_intensity_uchar (color);
pf->bg_color[0] = gimp_rgb_luminance_uchar (color);
break;
case 4: pf->bg_color[3] = 255;
......
......@@ -36,6 +36,8 @@ EXPORTS
gimp_rgb_intensity
gimp_rgb_intensity_uchar
gimp_rgb_list_names
gimp_rgb_luminance
gimp_rgb_luminance_uchar
gimp_rgb_max
gimp_rgb_min
gimp_rgb_multiply
......
......@@ -25,6 +25,7 @@
#include "gimpcolortypes.h"
#undef GIMP_DISABLE_DEPRECATED /* for GIMP_RGB_INTENSITY() */
#include "gimprgb.h"
......@@ -228,6 +229,50 @@ gimp_rgb_gamma (GimpRGB *rgb,
rgb->b = pow (rgb->b, ig);
}
/**
* gimp_rgb_luminance:
* @rgb:
*
* Return value: the luminous intensity of the range from 0.0 to 1.0.
*
* Since: GIMP 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:
*
* Return value: the luminous intensity in the range from 0 to 255.
*
* Since: GIMP 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);
}
/**
* gimp_rgb_intensity:
* @rgb:
*
* This function is deprecated! Use gimp_rgb_luminance() instead.
*
* Return value: the intensity in the range from 0.0 to 1.0.
**/
gdouble
gimp_rgb_intensity (const GimpRGB *rgb)
{
......@@ -240,6 +285,14 @@ gimp_rgb_intensity (const GimpRGB *rgb)
return CLAMP (intensity, 0.0, 1.0);
}
/**
* gimp_rgb_intensity_uchar:
* @rgb:
*
* This function is deprecated! Use gimp_rgb_luminance_uchar() instead.
*
* Return value: the intensity in the range from 0 to 255.
**/
guchar
gimp_rgb_intensity_uchar (const GimpRGB *rgb)
{
......
......@@ -99,8 +99,13 @@ void gimp_rgb_clamp (GimpRGB *rgb);
void gimp_rgb_gamma (GimpRGB *rgb,
gdouble gamma);
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
guchar gimp_rgb_intensity_uchar (const GimpRGB *rgb);
gdouble gimp_rgb_luminance (const GimpRGB *rgb);
guchar gimp_rgb_luminance_uchar (const GimpRGB *rgb);
#ifndef GIMP_DISABLE_DEPRECATED
gdouble gimp_rgb_intensity (const GimpRGB *rgb);
guchar gimp_rgb_intensity_uchar (const GimpRGB *rgb);
#endif
void gimp_rgb_composite (GimpRGB *color1,
const GimpRGB *color2,
......@@ -146,13 +151,44 @@ gdouble gimp_rgba_distance (const GimpRGB *rgba1,
/* Map RGB to intensity */
#define GIMP_RGB_INTENSITY_RED 0.30
#define GIMP_RGB_INTENSITY_GREEN 0.59
#define GIMP_RGB_INTENSITY_BLUE 0.11
/*
* The weights to compute true CIE luminance from linear red, green
* and blue, as defined by the ITU-R Recommendation BT.709, "Basic
* Parameter Values for the HDTV Standard for the Studio and for
* International Programme Exchange" (1990). Also suggested in the
* sRGB colorspace specification by the W3C.
*/
#define GIMP_RGB_LUMINANCE_RED (0.2126)
#define GIMP_RGB_LUMINANCE_GREEN (0.7152)
#define GIMP_RGB_LUMINANCE_BLUE (0.0722)
#define GIMP_RGB_LUMINANCE(r,g,b) ((r) * GIMP_RGB_LUMINANCE_RED + \
(g) * GIMP_RGB_LUMINANCE_GREEN + \
(b) * GIMP_RGB_LUMINANCE_BLUE)
#ifndef GIMP_DISABLE_DEPRECATED
/*
* The coefficients below properly computed luminance for monitors
* having phosphors that were contemporary at the introduction of NTSC
* television in 1953. They are still appropriate for computing video
* luma. However, these coefficients do not accurately compute
* luminance for contemporary monitors. The use of these definitions
* is deprecated.
*/
#define GIMP_RGB_INTENSITY_RED (0.30)
#define GIMP_RGB_INTENSITY_GREEN (0.59)
#define GIMP_RGB_INTENSITY_BLUE (0.11)
#define GIMP_RGB_INTENSITY(r,g,b) ((r) * GIMP_RGB_INTENSITY_RED + \
(g) * GIMP_RGB_INTENSITY_GREEN + \
(b) * GIMP_RGB_INTENSITY_BLUE)
#endif
G_END_DECLS
......
......@@ -325,7 +325,7 @@ colorsel_triangle_update_preview (ColorselTriangle *triangle)
gimp_hsv_to_rgb4 (buf, atn / (2 * G_PI), 1, 1);
col = GIMP_RGB_INTENSITY (buf[0], buf[1], buf[2]) > 127 ? 0 : 255;
col = GIMP_RGB_LUMINANCE (buf[0], buf[1], buf[2]) > 127 ? 0 : 255;
d = CLAMP (triangle->wheelradius / 16, 2, 4);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment