removed the addition of 0.001 that isn't correct for use with integers

2003-11-17  Sven Neumann  <sven@gimp.org>

	* libgimpcolor/gimprgb.h (GIMP_RGB_INTENSITY): removed the
	addition of 0.001 that isn't correct for use with integers (should
	be 0.5 then) and just plain wrong for use with floats/doubles.

	* app/base/temp-buf.c
	* app/core/gimpdrawable.c
	* app/core/gimpimage-convert.c
	* app/core/gimpimage.c
	* plug-ins/common/aa.c
	* plug-ins/common/engrave.c
	* plug-ins/common/gradmap.c
	* plug-ins/common/newsprint.c
	* plug-ins/gflare/gflare.c
	* plug-ins/gfli/gfli.c
	* plug-ins/pagecurl/pagecurl.c: add 0.5 to the result of
	GIMP_RGB_INTENSITY() in all places that use it with integers.
This commit is contained in:
Sven Neumann 2003-11-17 17:33:14 +00:00 committed by Sven Neumann
parent 2b230b9693
commit 83ae886609
12 changed files with 53 additions and 26 deletions

View File

@ -1,3 +1,22 @@
2003-11-17 Sven Neumann <sven@gimp.org>
* libgimpcolor/gimprgb.h (GIMP_RGB_INTENSITY): removed the
addition of 0.001 that isn't correct for use with integers (should
be 0.5 then) and just plain wrong for use with floats/doubles.
* app/base/temp-buf.c
* app/core/gimpdrawable.c
* app/core/gimpimage-convert.c
* app/core/gimpimage.c
* plug-ins/common/aa.c
* plug-ins/common/engrave.c
* plug-ins/common/gradmap.c
* plug-ins/common/newsprint.c
* plug-ins/gflare/gflare.c
* plug-ins/gfli/gfli.c
* plug-ins/pagecurl/pagecurl.c: add 0.5 to the result of
GIMP_RGB_INTENSITY() in all places that use it with integers.
2003-11-17 Michael Natterer <mitch@gimp.org>
* modules/colorsel_triangle.c (colorsel_triangle_update_previews):

View File

@ -135,7 +135,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]);
pix = GIMP_RGB_INTENSITY (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
src += 3;
@ -146,7 +146,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]);
pix = GIMP_RGB_INTENSITY (src[0], src[1], src[2]) + 0.5;
*dest++ = (guchar) pix;
*dest++ = src[3]; /* alpha channel */

View File

@ -788,7 +788,7 @@ gimp_drawable_fill (GimpDrawable *drawable,
case GIMP_GRAY:
c[GRAY_PIX] = GIMP_RGB_INTENSITY (c[RED_PIX],
c[GREEN_PIX],
c[BLUE_PIX]);
c[BLUE_PIX]) + 0.5;
c[ALPHA_G_PIX] = c[ALPHA_PIX];
if (drawable_type != GIMP_GRAYA_IMAGE)

View File

@ -1197,7 +1197,7 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
{
val = GIMP_RGB_INTENSITY (s[RED_PIX],
s[GREEN_PIX],
s[BLUE_PIX]);
s[BLUE_PIX]) + 0.5;
*d++ = (guchar) val;
s += 3;
if (has_alpha)
@ -1219,7 +1219,7 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
offset = *s++ * 3;
val = GIMP_RGB_INTENSITY (cmap[offset+0],
cmap[offset+1],
cmap[offset+2]);
cmap[offset+2]) + 0.5;
*d++ = (guchar) val;
if (has_alpha)
*d++ = *s++;

View File

@ -1605,7 +1605,8 @@ gimp_image_get_foreground (const GimpImage *gimage,
g_return_if_fail (! drawable || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (fg != NULL);
gimp_context_get_foreground (gimp_get_current_context (gimage->gimp), &color);
gimp_context_get_foreground (gimp_get_current_context (gimage->gimp),
&color);
gimp_rgb_get_uchar (&color, &pfg[0], &pfg[1], &pfg[2]);
@ -1624,7 +1625,8 @@ gimp_image_get_background (const GimpImage *gimage,
g_return_if_fail (! drawable || GIMP_IS_DRAWABLE (drawable));
g_return_if_fail (bg != NULL);
gimp_context_get_background (gimp_get_current_context (gimage->gimp), &color);
gimp_context_get_background (gimp_get_current_context (gimage->gimp),
&color);
gimp_rgb_get_uchar (&color, &pbg[0], &pbg[1], &pbg[2]);
@ -1641,21 +1643,24 @@ gimp_image_get_color (const GimpImage *src_gimage,
switch (src_type)
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
/* Straight copy */
*rgb++ = *src++;
*rgb++ = *src++;
*rgb = *src;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
/* Gray to RG&B */
*rgb++ = *src;
*rgb++ = *src;
*rgb = *src;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
/* Indexed palette lookup */
{
gint index = *src * 3;
@ -1702,7 +1707,7 @@ gimp_image_transform_color (const GimpImage *dest_gimage,
/* NTSC conversion */
*dest = GIMP_RGB_INTENSITY (src[RED_PIX],
src[GREEN_PIX],
src[BLUE_PIX]);
src[BLUE_PIX]) + 0.5;
break;
case GIMP_INDEXED_IMAGE:
@ -1719,19 +1724,22 @@ gimp_image_transform_color (const GimpImage *dest_gimage,
case GIMP_GRAY:
switch (dest_type)
{
case GIMP_RGB_IMAGE: case GIMP_RGBA_IMAGE:
case GIMP_RGB_IMAGE:
case GIMP_RGBA_IMAGE:
/* Gray to RG&B */
*dest++ = *src;
*dest++ = *src;
*dest++ = *src;
break;
case GIMP_GRAY_IMAGE: case GIMP_GRAYA_IMAGE:
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
/* Straight copy */
*dest = *src;
break;
case GIMP_INDEXED_IMAGE: case GIMP_INDEXEDA_IMAGE:
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
/* Least squares method */
*dest = gimp_image_color_hash_rgb_to_indexed (dest_gimage,
src[GRAY_PIX],

View File

@ -298,15 +298,15 @@ gimp2aa (gint32 drawable_ID,
case 3: /* RGB */
for (x = 0, p = buffer; x < width; x++, p += 3)
aa_putpixel (context, x, y, GIMP_RGB_INTENSITY (p[0], p[1], p[2]));
aa_putpixel (context, x, y,
GIMP_RGB_INTENSITY (p[0], p[1], p[2]) + 0.5);
break;
case 4: /* RGBA, blend over black */
for (x = 0, p = buffer; x < width; x++, p += 4)
aa_putpixel (context, x, y,
((guchar) GIMP_RGB_INTENSITY (p[0],
p[1],
p[2]) * (p[3] + 1)) >> 8);
((guchar) (GIMP_RGB_INTENSITY (p[0], p[1], p[2]) + 0.5)
* (p[3] + 1)) >> 8);
break;
default:

View File

@ -325,7 +325,7 @@ engrave_large (GimpDrawable *drawable,
average[b] = (guchar) (average[b] / count);
if (bpp < 3)
inten = average[0]/254.0*height;
inten = average[0] / 254.0 * height;
else
inten = GIMP_RGB_INTENSITY (average[0],
average[1],

View File

@ -66,7 +66,7 @@ static char rcsid[] = "$Id$";
#define NSAMPLES 256
#define TILE_CACHE_SIZE 32
#define LUMINOSITY(X) (GIMP_RGB_INTENSITY (X[0], X[1], X[2]))
#define LUMINOSITY(X) (GIMP_RGB_INTENSITY (X[0], X[1], X[2]) + 0.5)
static GimpRunMode run_mode;
@ -178,7 +178,7 @@ typedef struct {
gboolean has_alpha;
} GradMapParam_t;
static void
static void
gradmap_func (const guchar *src,
guchar *dest,
gint bpp,

View File

@ -1918,7 +1918,7 @@ do { \
data[3] = data[0]; /* save orig for later */
data[0] = GIMP_RGB_INTENSITY (data[0],
data[1],
data[2]);
data[2]) + 0.5;
break;
default:

View File

@ -70,7 +70,7 @@ static char rcsid[] = "$Id$";
#define DEBUG_PRINT(X)
#endif
#define LUMINOSITY(PIX) (GIMP_RGB_INTENSITY (PIX[0], PIX[1], PIX[2]))
#define LUMINOSITY(PIX) (GIMP_RGB_INTENSITY (PIX[0], PIX[1], PIX[2]) + 0.5)
#define OFFSETOF(t,f) ((int) ((char*) &((t*) 0)->f))
#define RESPONSE_RESCAN 1

View File

@ -642,7 +642,7 @@ save_image (const gchar *filename,
{
cm[i*3+0] = cm[i*3+1] = cm[i*3+2] = i;
}
bg = GIMP_RGB_INTENSITY (red, green, blue);
bg = GIMP_RGB_INTENSITY (red, green, blue) + 0.5;
break;
case GIMP_INDEXED:

View File

@ -782,10 +782,10 @@ do_curl_effect (void)
fore_grayval = GIMP_RGB_INTENSITY (fore_color[0],
fore_color[1],
fore_color[2]);
fore_color[2]) + 0.5;
back_grayval = GIMP_RGB_INTENSITY (back_color[0],
back_color[1],
back_color[2]);
back_color[2]) + 0.5;
/* Gradient Samples */
if (curl.do_curl_gradient)