app/core/gimpdrawable-transform.c minor cleanups to the new Lanczos

2005-01-15  Sven Neumann  <sven@gimp.org>

	* app/core/gimpdrawable-transform.c
	* app/paint-funcs/scale-funcs.c: minor cleanups to the new Lanczos
	interpolation routines. Drawable transformations do still crash :(
This commit is contained in:
Sven Neumann 2005-01-15 20:46:21 +00:00 committed by Sven Neumann
parent 4c7e91011a
commit f7234cc616
4 changed files with 71 additions and 75 deletions

View File

@ -1,3 +1,9 @@
2005-01-15 Sven Neumann <sven@gimp.org>
* app/core/gimpdrawable-transform.c
* app/paint-funcs/scale-funcs.c: minor cleanups to the new Lanczos
interpolation routines. Drawable transformations do still crash :(
2005-01-15 Michael Natterer <mitch@gimp.org>
* app/display/gimpdisplayshell-dnd.[ch]: added new function

View File

@ -103,7 +103,7 @@ static void sample_lanczos (const gdouble *kernel,
gint su,
gint sv,
guchar *color,
guchar *buffer,
const guchar *buffer,
gint bytes,
gint alpha);
@ -309,7 +309,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
break;
case GIMP_INTERPOLATION_LANCZOS:
kernel = kernel_lanczos ();
buffer = g_new0 (guchar, LANCZOS_WIDTH2 * bytes);
buffer = g_new0 (guchar, SQR (LANCZOS_WIDTH2) * bytes);
break;
}
@ -329,8 +329,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
{
if (progress && !(y & 0xf))
gimp_progress_set_value (progress,
(gdouble) (y - y1) /
(gdouble) (y2 - y1));
(gdouble) (y - y1) / (gdouble) (y2 - y1));
/* set up inverse transform steps */
tu[0] = uinc * x1 + m.coeff[0][1] * y + m.coeff[0][2];
@ -387,8 +386,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation_type == GIMP_INTERPOLATION_NONE)
{
guchar color[MAX_CHANNELS];
gint iu = (gint) u [0];
gint iv = (gint) v [0];
gint iu = (gint) u[0];
gint iv = (gint) v[0];
gint b;
if (iu >= u1 && iu < u2 &&
@ -414,9 +413,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
else if (interpolation_type == GIMP_INTERPOLATION_LANCZOS)
{
guchar color[MAX_CHANNELS];
gint iu = (gint) u [0];
gint iv = (gint) v [0];
gint fu,fv;
gint iu = (gint) u[0];
gint iv = (gint) v[0];
gint b;
if (iu >= u1 && iu < u2 &&
@ -427,17 +425,15 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gint v = iv - v1;
read_pixel_data (orig_tiles,
u-LANCZOS_WIDTH+1,
v-LANCZOS_WIDTH+1,
u+LANCZOS_WIDTH,
v+LANCZOS_WIDTH,
u - LANCZOS_WIDTH + 1,
v - LANCZOS_WIDTH + 1,
u + LANCZOS_WIDTH,
v + LANCZOS_WIDTH,
buffer,
bytes*LANCZOS_WIDTH2);
bytes * LANCZOS_WIDTH2);
fu = u-iu;
su = (gint)( fu * LANCZOS_SPP );
fv = v-iv;
sv = (gint)( fv * LANCZOS_SPP );
su = (gint) ((u - iu) * LANCZOS_SPP);
sv = (gint) ((v - iv) * LANCZOS_SPP);
sample_lanczos (kernel, su, sv, color, buffer, bytes, alpha);
@ -1722,17 +1718,18 @@ lanczos_sum (const guchar *buffer,
}
static inline gdouble
lanczos_sum_mul (guchar *buffer,
gdouble *l,
gint row,
gint bytes,
gint byte,
gint alpha)
lanczos_sum_mul (const guchar *buffer,
const gdouble *l,
gint row,
gint bytes,
gint byte,
gint alpha)
{
gdouble sum = 0;
gint j, k, p;
p = row * bytes * LANCZOS_WIDTH2;
for (k = 0, j = 0; j < LANCZOS_WIDTH2; j++, k++)
sum += (l[k] *
(buffer + p)[j * bytes + byte] *
@ -1766,7 +1763,7 @@ sample_lanczos (const gdouble *kernel,
gint su,
gint sv,
guchar *color,
guchar *buffer,
const guchar *buffer,
gint bytes,
gint alpha)
{

View File

@ -103,7 +103,7 @@ static void sample_lanczos (const gdouble *kernel,
gint su,
gint sv,
guchar *color,
guchar *buffer,
const guchar *buffer,
gint bytes,
gint alpha);
@ -309,7 +309,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
break;
case GIMP_INTERPOLATION_LANCZOS:
kernel = kernel_lanczos ();
buffer = g_new0 (guchar, LANCZOS_WIDTH2 * bytes);
buffer = g_new0 (guchar, SQR (LANCZOS_WIDTH2) * bytes);
break;
}
@ -329,8 +329,7 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
{
if (progress && !(y & 0xf))
gimp_progress_set_value (progress,
(gdouble) (y - y1) /
(gdouble) (y2 - y1));
(gdouble) (y - y1) / (gdouble) (y2 - y1));
/* set up inverse transform steps */
tu[0] = uinc * x1 + m.coeff[0][1] * y + m.coeff[0][2];
@ -387,8 +386,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
if (interpolation_type == GIMP_INTERPOLATION_NONE)
{
guchar color[MAX_CHANNELS];
gint iu = (gint) u [0];
gint iv = (gint) v [0];
gint iu = (gint) u[0];
gint iv = (gint) v[0];
gint b;
if (iu >= u1 && iu < u2 &&
@ -414,9 +413,8 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
else if (interpolation_type == GIMP_INTERPOLATION_LANCZOS)
{
guchar color[MAX_CHANNELS];
gint iu = (gint) u [0];
gint iv = (gint) v [0];
gint fu,fv;
gint iu = (gint) u[0];
gint iv = (gint) v[0];
gint b;
if (iu >= u1 && iu < u2 &&
@ -427,17 +425,15 @@ gimp_drawable_transform_tiles_affine (GimpDrawable *drawable,
gint v = iv - v1;
read_pixel_data (orig_tiles,
u-LANCZOS_WIDTH+1,
v-LANCZOS_WIDTH+1,
u+LANCZOS_WIDTH,
v+LANCZOS_WIDTH,
u - LANCZOS_WIDTH + 1,
v - LANCZOS_WIDTH + 1,
u + LANCZOS_WIDTH,
v + LANCZOS_WIDTH,
buffer,
bytes*LANCZOS_WIDTH2);
bytes * LANCZOS_WIDTH2);
fu = u-iu;
su = (gint)( fu * LANCZOS_SPP );
fv = v-iv;
sv = (gint)( fv * LANCZOS_SPP );
su = (gint) ((u - iu) * LANCZOS_SPP);
sv = (gint) ((v - iv) * LANCZOS_SPP);
sample_lanczos (kernel, su, sv, color, buffer, bytes, alpha);
@ -1722,17 +1718,18 @@ lanczos_sum (const guchar *buffer,
}
static inline gdouble
lanczos_sum_mul (guchar *buffer,
gdouble *l,
gint row,
gint bytes,
gint byte,
gint alpha)
lanczos_sum_mul (const guchar *buffer,
const gdouble *l,
gint row,
gint bytes,
gint byte,
gint alpha)
{
gdouble sum = 0;
gint j, k, p;
p = row * bytes * LANCZOS_WIDTH2;
for (k = 0, j = 0; j < LANCZOS_WIDTH2; j++, k++)
sum += (l[k] *
(buffer + p)[j * bytes + byte] *
@ -1766,7 +1763,7 @@ sample_lanczos (const gdouble *kernel,
gint su,
gint sv,
guchar *color,
guchar *buffer,
const guchar *buffer,
gint bytes,
gint alpha)
{

View File

@ -234,11 +234,10 @@ expand_line (gdouble *dest,
case GIMP_INTERPOLATION_NONE:
g_assert_not_reached ();
break;
/* Lanczos */
case GIMP_INTERPOLATION_LANCZOS:
g_assert_not_reached ();
break;
/* Lanczos */
}
}
@ -415,13 +414,11 @@ scale_region (PixelRegion *srcPR,
scale_region_no_resample (srcPR, destPR);
return;
}
/* Lanczos */
else if (interpolation == GIMP_INTERPOLATION_LANCZOS)
{
scale_region_lanczos(srcPR, destPR);
scale_region_lanczos (srcPR, destPR);
return;
}
/* Lanczos */
orig_width = srcPR->w;
orig_height = srcPR->h;
@ -544,11 +541,10 @@ scale_region (PixelRegion *srcPR,
case GIMP_INTERPOLATION_NONE:
g_assert_not_reached ();
break;
/* Lanczos */
case GIMP_INTERPOLATION_LANCZOS:
g_assert_not_reached ();
break;
/* Lanczos */
}
}
else /* height == orig_height */
@ -807,12 +803,12 @@ sinc (gdouble x)
}
static inline gdouble
lanczos_sum (guchar **src,
gdouble *l,
gint row,
gint col,
gint bytes,
gint byte)
lanczos_sum (guchar **src,
const gdouble *l,
gint row,
gint col,
gint bytes,
gint byte)
{
gdouble sum = 0;
gint j, k;
@ -835,13 +831,13 @@ lanczos_sum (guchar **src,
}
static inline gdouble
lanczos_sum_mul (guchar **src,
gdouble *l,
gint row,
gint col,
gint bytes,
gint byte,
gint alpha)
lanczos_sum_mul (guchar **src,
const gdouble *l,
gint row,
gint col,
gint bytes,
gint byte,
gint alpha)
{
gdouble sum = 0;
gint j, k;
@ -975,19 +971,20 @@ scale_region_lanczos (PixelRegion *srcPR,
v = (gint) dv;
/* make sure we have enough data available */
if ( srcrow < v+LANCZOS_WIDTH && srcrow < src_height-1 )
if (srcrow < v + LANCZOS_WIDTH && srcrow < src_height-1 )
{
for ( i = srcrow+1 ; i <= v+LANCZOS_WIDTH ; i++)
for (i = srcrow + 1; i <= v + LANCZOS_WIDTH; i++)
{
/* 2nd row in src buffer becomes first */
rotate_pointers(src, LANCZOS_WIDTH2);
rotate_pointers (src, LANCZOS_WIDTH2);
/* Make sure we do not read past the end of image */
srcrow = ( i < src_height ) ? i : src_height - 1;
/* append row at the end src buffer*/
pos = LANCZOS_WIDTH2-1;
pos = LANCZOS_WIDTH2 - 1;
pixel_region_get_row (srcPR,
0, srcrow, src_width, src[pos], 1);
}
/* current src(v) line in sliding window */
cur_buf = src[LANCZOS_WIDTH-1];
}
@ -1080,4 +1077,3 @@ scale_region_lanczos (PixelRegion *srcPR,
g_free (dst_buf);
g_free (kernel);
}
/* End Lanczos */