Commit e38ca549 authored by Martin Nordholts's avatar Martin Nordholts
Browse files

Rename the convenient channel offset defines from FOO_PIX to FOO as this

* app/base/base-types.h: Rename the convenient channel offset
defines from FOO_PIX to FOO as this increases readability.

* app/base/color-balance.c
* app/base/colorize.c
* app/base/desaturate.c
* app/base/hue-saturation.c
* app/base/siox.c
* app/base/threshold.c

* app/core/gimp-edit.c
* app/core/gimp-transform-region.c
* app/core/gimpchannel.c
* app/core/gimpdrawable-bucket-fill.c
* app/core/gimpdrawable-convert.c
* app/core/gimpdrawable-stroke.c
* app/core/gimpdrawable.c
* app/core/gimpimage-convert.c
* app/core/gimpimage.c
* app/core/gimppalette-import.c
* app/core/gimppickable.c

* app/gegl/gimpoperation*mode.c
* app/gegl/gimpoperationcolorbalance.c
* app/gegl/gimpoperationcolorize.c
* app/gegl/gimpoperationhuesaturation.c
* app/gegl/gimpoperationlevels.c
* app/gegl/gimpoperationposterize.c
* app/gegl/gimpoperationthreshold.c

* app/paint-funcs/subsample-region.c

* app/paint/gimpclone.c
* app/paint/gimppaintbrush.c

* app/widgets/gimpviewrenderer.c: Adapt.

svn path=/trunk/; revision=27324
parent 6204aa32
2008-10-19 Martin Nordholts <martinn@svn.gnome.org>
* app/base/base-types.h: Rename the convenient channel offset
defines from FOO_PIX to FOO as this increases readability.
* app/base/color-balance.c
* app/base/colorize.c
* app/base/desaturate.c
* app/base/hue-saturation.c
* app/base/siox.c
* app/base/threshold.c
* app/core/gimp-edit.c
* app/core/gimp-transform-region.c
* app/core/gimpchannel.c
* app/core/gimpdrawable-bucket-fill.c
* app/core/gimpdrawable-convert.c
* app/core/gimpdrawable-stroke.c
* app/core/gimpdrawable.c
* app/core/gimpimage-convert.c
* app/core/gimpimage.c
* app/core/gimppalette-import.c
* app/core/gimppickable.c
* app/gegl/gimpoperation*mode.c
* app/gegl/gimpoperationcolorbalance.c
* app/gegl/gimpoperationcolorize.c
* app/gegl/gimpoperationhuesaturation.c
* app/gegl/gimpoperationlevels.c
* app/gegl/gimpoperationposterize.c
* app/gegl/gimpoperationthreshold.c
* app/paint-funcs/subsample-region.c
* app/paint/gimpclone.c
* app/paint/gimppaintbrush.c
* app/widgets/gimpviewrenderer.c: Adapt.
2008-10-19 Sven Neumann <sven@gimp.org>
Bug 493778 – metadata plug-in crashes on some images
......
......@@ -32,16 +32,18 @@
/* convenient defines */
#define MAX_CHANNELS 4
#define GRAY_PIX 0
#define ALPHA_G_PIX 1
#define RED_PIX 0
#define GREEN_PIX 1
#define BLUE_PIX 2
#define ALPHA_PIX 3
#define INDEXED_PIX 0
#define ALPHA_I_PIX 1
#define MAX_CHANNELS 4
#define RED 0
#define GREEN 1
#define BLUE 2
#define ALPHA 3
#define GRAY 0
#define ALPHA_G 1
#define INDEXED 0
#define ALPHA_I 1
/* types */
......
......@@ -190,9 +190,9 @@ color_balance (ColorBalance *cb,
while (w--)
{
r = s[RED_PIX];
g = s[GREEN_PIX];
b = s[BLUE_PIX];
r = s[RED];
g = s[GREEN];
b = s[BLUE];
r_n = cb->r_lookup[r];
g_n = cb->g_lookup[g];
......@@ -205,12 +205,12 @@ color_balance (ColorBalance *cb,
gimp_hsl_to_rgb_int (&r_n, &g_n, &b_n);
}
d[RED_PIX] = r_n;
d[GREEN_PIX] = g_n;
d[BLUE_PIX] = b_n;
d[RED] = r_n;
d[GREEN] = g_n;
d[BLUE] = b_n;
if (alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
s += srcPR->bytes;
d += destPR->bytes;
......
......@@ -102,9 +102,9 @@ colorize (Colorize *colorize,
while (w--)
{
lum = (colorize->lum_red_lookup[s[RED_PIX]] +
colorize->lum_green_lookup[s[GREEN_PIX]] +
colorize->lum_blue_lookup[s[BLUE_PIX]]); /* luminosity */
lum = (colorize->lum_red_lookup[s[RED]] +
colorize->lum_green_lookup[s[GREEN]] +
colorize->lum_blue_lookup[s[BLUE]]); /* luminosity */
if (colorize->lightness > 0)
{
......@@ -117,12 +117,12 @@ colorize (Colorize *colorize,
lum = (gdouble) lum * (colorize->lightness + 100.0) / 100.0;
}
d[RED_PIX] = colorize->final_red_lookup[lum];
d[GREEN_PIX] = colorize->final_green_lookup[lum];
d[BLUE_PIX] = colorize->final_blue_lookup[lum];
d[RED] = colorize->final_red_lookup[lum];
d[GREEN] = colorize->final_green_lookup[lum];
d[BLUE] = colorize->final_blue_lookup[lum];
if (alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
s += srcPR->bytes;
d += destPR->bytes;
......
......@@ -84,19 +84,19 @@ desaturate_region_lightness (PixelRegion *srcPR,
gint min, max;
gint lightness;
max = MAX (s[RED_PIX], s[GREEN_PIX]);
max = MAX (max, s[BLUE_PIX]);
min = MIN (s[RED_PIX], s[GREEN_PIX]);
min = MIN (min, s[BLUE_PIX]);
max = MAX (s[RED], s[GREEN]);
max = MAX (max, s[BLUE]);
min = MIN (s[RED], s[GREEN]);
min = MIN (min, s[BLUE]);
lightness = (max + min) / 2;
d[RED_PIX] = lightness;
d[GREEN_PIX] = lightness;
d[BLUE_PIX] = lightness;
d[RED] = lightness;
d[GREEN] = lightness;
d[BLUE] = lightness;
if (has_alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
d += destPR->bytes;
s += srcPR->bytes;
......@@ -124,16 +124,16 @@ desaturate_region_luminosity (PixelRegion *srcPR,
for (j = 0; j < srcPR->w; j++)
{
gint luminosity = GIMP_RGB_LUMINANCE (s[RED_PIX],
s[GREEN_PIX],
s[BLUE_PIX]) + 0.5;
gint luminosity = GIMP_RGB_LUMINANCE (s[RED],
s[GREEN],
s[BLUE]) + 0.5;
d[RED_PIX] = luminosity;
d[GREEN_PIX] = luminosity;
d[BLUE_PIX] = luminosity;
d[RED] = luminosity;
d[GREEN] = luminosity;
d[BLUE] = luminosity;
if (has_alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
d += destPR->bytes;
s += srcPR->bytes;
......@@ -161,14 +161,14 @@ desaturate_region_average (PixelRegion *srcPR,
for (j = 0; j < srcPR->w; j++)
{
gint average = (s[RED_PIX] + s[GREEN_PIX] + s[BLUE_PIX] + 1) / 3;
gint average = (s[RED] + s[GREEN] + s[BLUE] + 1) / 3;
d[RED_PIX] = average;
d[GREEN_PIX] = average;
d[BLUE_PIX] = average;
d[RED] = average;
d[GREEN] = average;
d[BLUE] = average;
if (has_alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
d += destPR->bytes;
s += srcPR->bytes;
......
......@@ -126,9 +126,9 @@ hue_saturation (HueSaturation *hs,
while (w--)
{
r = s[RED_PIX];
g = s[GREEN_PIX];
b = s[BLUE_PIX];
r = s[RED];
g = s[GREEN];
b = s[BLUE];
gimp_rgb_to_hsl_int (&r, &g, &b);
......@@ -194,12 +194,12 @@ hue_saturation (HueSaturation *hs,
gimp_hsl_to_rgb_int (&r, &g, &b);
d[RED_PIX] = r;
d[GREEN_PIX] = g;
d[BLUE_PIX] = b;
d[RED] = r;
d[GREEN] = g;
d[BLUE] = b;
if (alpha)
d[ALPHA_PIX] = s[ALPHA_PIX];
d[ALPHA] = s[ALPHA];
s += srcPR->bytes;
d += destPR->bytes;
......
......@@ -143,9 +143,9 @@ calc_lab (const guchar *src,
{
case 3: /* RGB */
case 4: /* RGBA */
cpercep_rgb_to_space (src[RED_PIX],
src[GREEN_PIX],
src[BLUE_PIX], &l, &a, &b);
cpercep_rgb_to_space (src[RED],
src[GREEN],
src[BLUE], &l, &a, &b);
break;
case 2:
......@@ -154,9 +154,9 @@ calc_lab (const guchar *src,
{
gint i = *src * 3;
cpercep_rgb_to_space (colormap[i + RED_PIX],
colormap[i + GREEN_PIX],
colormap[i + BLUE_PIX], &l, &a, &b);
cpercep_rgb_to_space (colormap[i + RED],
colormap[i + GREEN],
colormap[i + BLUE], &l, &a, &b);
}
else /* GRAY(A) */
{
......@@ -691,16 +691,16 @@ create_key (const guchar *src,
{
case 3: /* RGB */
case 4: /* RGBA */
return (src[RED_PIX] << 16 | src[GREEN_PIX] << 8 | src[BLUE_PIX]);
return (src[RED] << 16 | src[GREEN] << 8 | src[BLUE]);
case 2:
case 1:
if (colormap) /* INDEXED(A) */
{
gint i = *src * 3;
return (colormap[i + RED_PIX] << 16 |
colormap[i + GREEN_PIX] << 8 |
colormap[i + BLUE_PIX]);
return (colormap[i + RED] << 16 |
colormap[i + GREEN] << 8 |
colormap[i + BLUE]);
}
else /* GRAY(A) */
{
......
......@@ -54,16 +54,16 @@ threshold (Threshold *tr,
{
if (tr->color)
{
value = MAX (s[RED_PIX], s[GREEN_PIX]);
value = MAX (value, s[BLUE_PIX]);
value = MAX (s[RED], s[GREEN]);
value = MAX (value, s[BLUE]);
value = (value >= tr->low_threshold &&
value <= tr->high_threshold ) ? 255 : 0;
}
else
{
value = (s[GRAY_PIX] >= tr->low_threshold &&
s[GRAY_PIX] <= tr->high_threshold) ? 255 : 0;
value = (s[GRAY] >= tr->low_threshold &&
s[GRAY] <= tr->high_threshold) ? 255 : 0;
}
for (b = 0; b < alpha; b++)
......
......@@ -612,9 +612,9 @@ gimp_edit_fill_internal (GimpImage *image,
{
guchar tmp_col[MAX_CHANNELS];
tmp_col[RED_PIX] = 255;
tmp_col[GREEN_PIX] = 255;
tmp_col[BLUE_PIX] = 255;
tmp_col[RED] = 255;
tmp_col[GREEN] = 255;
tmp_col[BLUE] = 255;
gimp_image_transform_color (image, drawable_type, col,
GIMP_RGB, tmp_col);
}
......
......@@ -210,18 +210,18 @@ gimp_transform_region (GimpPickable *pickable,
switch (GIMP_IMAGE_TYPE_BASE_TYPE (pickable_type))
{
case GIMP_RGB:
bg_color[ALPHA_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_PIX;
bg_color[ALPHA] = TRANSPARENT_OPACITY;
alpha = ALPHA;
break;
case GIMP_GRAY:
bg_color[ALPHA_G_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_G_PIX;
bg_color[ALPHA_G] = TRANSPARENT_OPACITY;
alpha = ALPHA_G;
break;
case GIMP_INDEXED:
bg_color[ALPHA_I_PIX] = TRANSPARENT_OPACITY;
alpha = ALPHA_I_PIX;
bg_color[ALPHA_I] = TRANSPARENT_OPACITY;
alpha = ALPHA_I;
/* If the image is indexed color, ignore interpolation value */
interpolation_type = GIMP_INTERPOLATION_NONE;
break;
......
......@@ -767,8 +767,8 @@ gimp_channel_get_active_components (const GimpDrawable *drawable,
gboolean *active)
{
/* Make sure that the alpha channel is not valid. */
active[GRAY_PIX] = TRUE;
active[ALPHA_G_PIX] = FALSE;
active[GRAY] = TRUE;
active[ALPHA_G] = FALSE;
}
static void
......
......@@ -157,9 +157,9 @@ gimp_drawable_bucket_fill_full (GimpDrawable *drawable,
guchar tmp_col[MAX_CHANNELS];
gimp_rgb_get_uchar (color,
&tmp_col[RED_PIX],
&tmp_col[GREEN_PIX],
&tmp_col[BLUE_PIX]);
&tmp_col[RED],
&tmp_col[GREEN],
&tmp_col[BLUE]);
gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
GIMP_RGB, tmp_col);
......
......@@ -84,9 +84,9 @@ gimp_drawable_convert_rgb (GimpDrawable *drawable,
for (col = 0; col < srcPR.w; col++)
{
d[RED_PIX] = *s;
d[GREEN_PIX] = *s;
d[BLUE_PIX] = *s;
d[RED] = *s;
d[GREEN] = *s;
d[BLUE] = *s;
d += 3;
s++;
......@@ -116,9 +116,9 @@ gimp_drawable_convert_rgb (GimpDrawable *drawable,
for (col = 0; col < srcPR.w; col++)
{
offset = *s++ * 3;
d[RED_PIX] = cmap[offset + 0];
d[GREEN_PIX] = cmap[offset + 1];
d[BLUE_PIX] = cmap[offset + 2];
d[RED] = cmap[offset + 0];
d[GREEN] = cmap[offset + 1];
d[BLUE] = cmap[offset + 2];
d += 3;
if (has_alpha)
......@@ -186,9 +186,9 @@ gimp_drawable_convert_grayscale (GimpDrawable *drawable,
d = dest;
for (col = 0; col < srcPR.w; col++)
{
val = GIMP_RGB_LUMINANCE (s[RED_PIX],
s[GREEN_PIX],
s[BLUE_PIX]) + 0.5;
val = GIMP_RGB_LUMINANCE (s[RED],
s[GREEN],
s[BLUE]) + 0.5;
*d++ = (guchar) val;
s += 3;
if (has_alpha)
......
......@@ -287,9 +287,9 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
guchar col[MAX_CHANNELS] = { 0, };
gimp_rgb_get_uchar (&context->foreground,
&tmp_col[RED_PIX],
&tmp_col[GREEN_PIX],
&tmp_col[BLUE_PIX]);
&tmp_col[RED],
&tmp_col[GREEN],
&tmp_col[BLUE]);
gimp_image_transform_color (image, gimp_drawable_type (drawable), col,
GIMP_RGB, tmp_col);
......
......@@ -1253,15 +1253,15 @@ gimp_drawable_fill (GimpDrawable *drawable,
guchar c[MAX_CHANNELS];
gimp_rgba_get_uchar (color,
&tmp[RED_PIX],
&tmp[GREEN_PIX],
&tmp[BLUE_PIX],
&tmp[ALPHA_PIX]);
&tmp[RED],
&tmp[GREEN],
&tmp[BLUE],
&tmp[ALPHA]);
gimp_image_transform_color (image, drawable_type, c, GIMP_RGB, tmp);
if (GIMP_IMAGE_TYPE_HAS_ALPHA (drawable_type))
c[GIMP_IMAGE_TYPE_BYTES (drawable_type) - 1] = tmp[ALPHA_PIX];
c[GIMP_IMAGE_TYPE_BYTES (drawable_type) - 1] = tmp[ALPHA];
else
c[GIMP_IMAGE_TYPE_BYTES (drawable_type)] = OPAQUE_OPACITY;
......
This diff is collapsed.
......@@ -1661,17 +1661,17 @@ gimp_image_get_component_index (const GimpImage *image,
switch (channel)
{
case GIMP_RED_CHANNEL: return RED_PIX;
case GIMP_GREEN_CHANNEL: return GREEN_PIX;
case GIMP_BLUE_CHANNEL: return BLUE_PIX;
case GIMP_GRAY_CHANNEL: return GRAY_PIX;
case GIMP_INDEXED_CHANNEL: return INDEXED_PIX;
case GIMP_RED_CHANNEL: return RED;
case GIMP_GREEN_CHANNEL: return GREEN;
case GIMP_BLUE_CHANNEL: return BLUE;
case GIMP_GRAY_CHANNEL: return GRAY;
case GIMP_INDEXED_CHANNEL: return INDEXED;
case GIMP_ALPHA_CHANNEL:
switch (gimp_image_base_type (image))
{
case GIMP_RGB: return ALPHA_PIX;
case GIMP_GRAY: return ALPHA_G_PIX;
case GIMP_INDEXED: return ALPHA_I_PIX;
case GIMP_RGB: return ALPHA;
case GIMP_GRAY: return ALPHA_G;
case GIMP_INDEXED: return ALPHA_I;
}
}
......@@ -2220,18 +2220,18 @@ gimp_image_transform_color (const GimpImage *dest_image,
case GIMP_GRAY_IMAGE:
case GIMP_GRAYA_IMAGE:
/* NTSC conversion */
*dest = GIMP_RGB_LUMINANCE (src[RED_PIX],
src[GREEN_PIX],
src[BLUE_PIX]) + 0.5;
*dest = GIMP_RGB_LUMINANCE (src[RED],
src[GREEN],
src[BLUE]) + 0.5;
break;
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
/* Least squares method */
*dest = gimp_image_color_hash_rgb_to_indexed (dest_image,
src[RED_PIX],
src[GREEN_PIX],
src[BLUE_PIX]);
src[RED],
src[GREEN],
src[BLUE]);
break;
}
break;
......@@ -2257,9 +2257,9 @@ gimp_image_transform_color (const GimpImage *dest_image,
case GIMP_INDEXEDA_IMAGE:
/* Least squares method */
*dest = gimp_image_color_hash_rgb_to_indexed (dest_image,
src[GRAY_PIX],
src[GRAY_PIX],
src[GRAY_PIX]);
src[GRAY],
src[GRAY],
src[GRAY]);
break;
}
break;
......
......@@ -323,7 +323,7 @@ gimp_palette_import_extract (GimpImage *image,
gimp_image_get_color (image, type, idata, rgba);
/* ignore completely transparent pixels */
if (rgba[ALPHA_PIX])
if (rgba[ALPHA])
{
guchar rgb_real[MAX_CHANNELS];
......
......@@ -227,16 +227,16 @@ gimp_pickable_pick_color (GimpPickable *pickable,
gimp_image_get_color (image, type, pixel, col);
color_avg[RED_PIX] += col[RED_PIX];
color_avg[GREEN_PIX] += col[GREEN_PIX];
color_avg[BLUE_PIX] += col[BLUE_PIX];
color_avg[ALPHA_PIX] += col[ALPHA_PIX];
color_avg[RED] += col[RED];
color_avg[GREEN] += col[GREEN];
color_avg[BLUE] += col[BLUE];
color_avg[ALPHA] += col[ALPHA];
}
col[RED_PIX] = (guchar) ((color_avg[RED_PIX] + count / 2) / count);
col[GREEN_PIX] = (guchar) ((color_avg[GREEN_PIX] + count / 2) / count);
col[BLUE_PIX] = (guchar) ((color_avg[BLUE_PIX] + count / 2) / count);
col[ALPHA_PIX] = (guchar) ((color_avg[ALPHA_PIX] + count / 2) / count);
col[RED] = (guchar) ((color_avg[RED] + count / 2) / count);
col[GREEN] = (guchar) ((color_avg[GREEN] + count / 2) / count);
col[BLUE] = (guchar) ((color_avg[BLUE] + count / 2) / count);
col[ALPHA] = (guchar) ((color_avg[ALPHA] + count / 2) / count);
}
else
{
......@@ -245,10 +245,10 @@ gimp_pickable_pick_color (GimpPickable *pickable,
gimp_rgba_set_uchar (color,
col[RED_PIX],
col[GREEN_PIX],
col[BLUE_PIX],
col[ALPHA_PIX]);
col[RED],
col[GREEN],
col[BLUE],
col[ALPHA]);
if (color_index)
{
......
......@@ -71,10 +71,10 @@ gimp_operation_anti_erase_mode_process (GeglOperation *operation,
while (samples--)
{
dest[RED_PIX] = src[RED_PIX];
dest[GREEN_PIX] = src[GREEN_PIX];
dest[BLUE_PIX] = src[BLUE_PIX];
dest[ALPHA_PIX] = src[ALPHA_PIX];
dest[RED] = src[RED];
dest[GREEN] = src[GREEN];
dest[BLUE] = src[BLUE];
dest[ALPHA] = src[ALPHA];
src += 4;
aux += 4;
......
Markdown is supported
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