minor cleanups.
2008-01-28 Sven Neumann <sven@gimp.org> * plug-ins/common/cubism.c: minor cleanups. svn path=/trunk/; revision=24729
This commit is contained in:

committed by
Sven Neumann

parent
bea90af290
commit
d3e1c997c9
@ -1,3 +1,7 @@
|
|||||||
|
2008-01-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/common/cubism.c: minor cleanups.
|
||||||
|
|
||||||
2008-01-28 Michael Natterer <mitch@gimp.org>
|
2008-01-28 Michael Natterer <mitch@gimp.org>
|
||||||
|
|
||||||
* app/base/tile-manager.c
|
* app/base/tile-manager.c
|
||||||
|
@ -424,12 +424,13 @@ cubism (GimpDrawable *drawable,
|
|||||||
pr = gimp_pixel_rgns_process (pr))
|
pr = gimp_pixel_rgns_process (pr))
|
||||||
{
|
{
|
||||||
count = src_rgn.w * src_rgn.h;
|
count = src_rgn.w * src_rgn.h;
|
||||||
dest = src_rgn.data;
|
dest = src_rgn.data;
|
||||||
|
|
||||||
while (count--)
|
while (count--)
|
||||||
for (i = 0; i < bytes; i++)
|
for (i = 0; i < bytes; i++)
|
||||||
*dest++ = bg_col[i];
|
*dest++ = bg_col[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
dest = NULL;
|
dest = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -440,11 +441,10 @@ cubism (GimpDrawable *drawable,
|
|||||||
|
|
||||||
randomize_indices (num_tiles, random_indices);
|
randomize_indices (num_tiles, random_indices);
|
||||||
|
|
||||||
count = 0;
|
|
||||||
gimp_pixel_rgn_init (&src_rgn, drawable,
|
gimp_pixel_rgn_init (&src_rgn, drawable,
|
||||||
x1, y1, x2 - x1, y2 - y1, FALSE, FALSE);
|
x1, y1, x2 - x1, y2 - y1, FALSE, FALSE);
|
||||||
|
|
||||||
while (count < num_tiles)
|
for (count = 0; count < num_tiles; count++)
|
||||||
{
|
{
|
||||||
i = random_indices[count] / (cols + 1);
|
i = random_indices[count] / (cols + 1);
|
||||||
j = random_indices[count] % (cols + 1);
|
j = random_indices[count] % (cols + 1);
|
||||||
@ -473,14 +473,13 @@ cubism (GimpDrawable *drawable,
|
|||||||
|
|
||||||
gimp_pixel_rgn_get_pixel (&src_rgn, col, ix, iy);
|
gimp_pixel_rgn_get_pixel (&src_rgn, col, ix, iy);
|
||||||
|
|
||||||
if (!has_alpha || col[bytes - 1])
|
if (! has_alpha || col[bytes - 1])
|
||||||
fill_poly_color (&poly, drawable, preview, col, dest);
|
fill_poly_color (&poly, drawable, preview, col, dest);
|
||||||
|
|
||||||
count++;
|
if (! preview)
|
||||||
if (!preview)
|
|
||||||
{
|
{
|
||||||
if ((count % 5) == 0)
|
if (count % 8 == 0)
|
||||||
gimp_progress_update ((double) count / (double) num_tiles);
|
gimp_progress_update ((gdouble) count / (gdouble) num_tiles);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -510,17 +509,12 @@ calc_alpha_blend (gdouble *vec,
|
|||||||
{
|
{
|
||||||
gdouble r;
|
gdouble r;
|
||||||
|
|
||||||
if (!one_over_dist)
|
if (! one_over_dist)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
else
|
|
||||||
{
|
r = (vec[0] * x + vec[1] * y) * one_over_dist;
|
||||||
r = (vec[0] * x + vec[1] * y) * one_over_dist;
|
|
||||||
if (r < 0.2)
|
return CLAMP (r, 0.2, 1.0);
|
||||||
r = 0.2;
|
|
||||||
else if (r > 1.0)
|
|
||||||
r = 1.0;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -611,8 +605,8 @@ fill_poly_color (Polygon *poly,
|
|||||||
|
|
||||||
if (poly->npts)
|
if (poly->npts)
|
||||||
{
|
{
|
||||||
gint poly_npts = poly->npts;
|
|
||||||
GimpVector2 *curptr;
|
GimpVector2 *curptr;
|
||||||
|
gint poly_npts = poly->npts;
|
||||||
|
|
||||||
xs = (gint) (poly->pts[poly_npts-1].x);
|
xs = (gint) (poly->pts[poly_npts-1].x);
|
||||||
ys = (gint) (poly->pts[poly_npts-1].y);
|
ys = (gint) (poly->pts[poly_npts-1].y);
|
||||||
@ -685,7 +679,10 @@ fill_poly_color (Polygon *poly,
|
|||||||
if (val > 0)
|
if (val > 0)
|
||||||
{
|
{
|
||||||
xx = (gdouble) j / (gdouble) SUPERSAMPLE + min_x;
|
xx = (gdouble) j / (gdouble) SUPERSAMPLE + min_x;
|
||||||
alpha = (gint) (val * calc_alpha_blend (vec, one_over_dist, xx - sx, yy - sy));
|
alpha = (gint) (val * calc_alpha_blend (vec,
|
||||||
|
one_over_dist,
|
||||||
|
xx - sx,
|
||||||
|
yy - sy));
|
||||||
if (preview)
|
if (preview)
|
||||||
{
|
{
|
||||||
for (b = 0; b < bytes; b++)
|
for (b = 0; b < bytes; b++)
|
||||||
@ -698,13 +695,13 @@ fill_poly_color (Polygon *poly,
|
|||||||
|
|
||||||
#ifndef USE_READABLE_BUT_SLOW_CODE
|
#ifndef USE_READABLE_BUT_SLOW_CODE
|
||||||
{
|
{
|
||||||
guchar *buf_iter = buf,
|
guchar *buf_iter = buf;
|
||||||
*col_iter = col,
|
guchar *col_iter = col;
|
||||||
*buf_end = buf+bytes;
|
guchar *buf_end = buf + bytes;
|
||||||
|
|
||||||
for(; buf_iter < buf_end; buf_iter++, col_iter++)
|
for(; buf_iter < buf_end; buf_iter++, col_iter++)
|
||||||
*buf_iter = ((guint)(*col_iter * alpha)
|
*buf_iter = ((guint) (*col_iter * alpha)
|
||||||
+ (((guint)*buf_iter)
|
+ (((guint) *buf_iter)
|
||||||
* (256 - alpha))) >> 8;
|
* (256 - alpha))) >> 8;
|
||||||
}
|
}
|
||||||
#else /* original, pre-ECL code */
|
#else /* original, pre-ECL code */
|
||||||
|
Reference in New Issue
Block a user