mirror of https://github.com/GNOME/gimp.git
major speedup for dithering code thanks to a suggestion from Jay Cox.
2005-02-28 Sven Neumann <sven@gimp.org> * app/core/gimpdrawable-blend.c: major speedup for dithering code thanks to a suggestion from Jay Cox.
This commit is contained in:
parent
c0c6d837c0
commit
d9e6ef3d93
|
@ -1,3 +1,8 @@
|
||||||
|
2005-02-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
|
* app/core/gimpdrawable-blend.c: major speedup for dithering code
|
||||||
|
thanks to a suggestion from Jay Cox.
|
||||||
|
|
||||||
2005-02-28 Sven Neumann <sven@gimp.org>
|
2005-02-28 Sven Neumann <sven@gimp.org>
|
||||||
|
|
||||||
* app/widgets/gimphelp.c (gimp_help_get_locales): use
|
* app/widgets/gimphelp.c (gimp_help_get_locales): use
|
||||||
|
|
|
@ -178,17 +178,6 @@ static PixelRegion distR =
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define gradient_dither(dest, rng, value) G_STMT_START { \
|
|
||||||
gdouble ftmp = (value) * 255.0; \
|
|
||||||
gint itmp = ftmp; \
|
|
||||||
\
|
|
||||||
if (g_rand_double (rng) > ftmp - itmp) \
|
|
||||||
*dest++ = itmp; \
|
|
||||||
else \
|
|
||||||
*dest++ = MIN (itmp + 1, 255); \
|
|
||||||
} G_STMT_END
|
|
||||||
|
|
||||||
|
|
||||||
/* public functions */
|
/* public functions */
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -813,10 +802,12 @@ gradient_put_pixel (gint x,
|
||||||
{
|
{
|
||||||
if (ppd->dither_rand)
|
if (ppd->dither_rand)
|
||||||
{
|
{
|
||||||
gradient_dither (dest, ppd->dither_rand, color->r);
|
gint i = g_rand_int (ppd->dither_rand);
|
||||||
gradient_dither (dest, ppd->dither_rand, color->g);
|
|
||||||
gradient_dither (dest, ppd->dither_rand, color->b);
|
*dest++ = color->r * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
gradient_dither (dest, ppd->dither_rand, color->a);
|
*dest++ = color->g * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
|
*dest++ = color->b * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
|
*dest++ = color->a * 255.0 + (gdouble) (i & 0xff) / 256.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -833,8 +824,10 @@ gradient_put_pixel (gint x,
|
||||||
|
|
||||||
if (ppd->dither_rand)
|
if (ppd->dither_rand)
|
||||||
{
|
{
|
||||||
gradient_dither (dest, ppd->dither_rand, gray);
|
gint i = g_rand_int (ppd->dither_rand);
|
||||||
gradient_dither (dest, ppd->dither_rand, color->a);
|
|
||||||
|
*dest++ = gray * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
|
*dest++ = color->a * 255.0 + (gdouble) (i & 0xff) / 256.0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -1056,13 +1049,14 @@ gradient_fill_single_region_rgb_dither (RenderBlendData *rbd,
|
||||||
for (x = PR->x; x < endx; x++)
|
for (x = PR->x; x < endx; x++)
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
gint i = g_rand_int (dither_rand);
|
||||||
|
|
||||||
gradient_render_pixel (x, y, &color, rbd);
|
gradient_render_pixel (x, y, &color, rbd);
|
||||||
|
|
||||||
gradient_dither (dest, dither_rand, color.r);
|
*dest++ = color.r * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
gradient_dither (dest, dither_rand, color.g);
|
*dest++ = color.g * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
gradient_dither (dest, dither_rand, color.b);
|
*dest++ = color.b * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
gradient_dither (dest, dither_rand, color.a);
|
*dest++ = color.a * 255.0 + (gdouble) (i & 0xff) / 256.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_rand_free (dither_rand);
|
g_rand_free (dither_rand);
|
||||||
|
@ -1103,11 +1097,15 @@ gradient_fill_single_region_gray_dither (RenderBlendData *rbd,
|
||||||
for (x = PR->x; x < endx; x++)
|
for (x = PR->x; x < endx; x++)
|
||||||
{
|
{
|
||||||
GimpRGB color;
|
GimpRGB color;
|
||||||
|
gdouble gray;
|
||||||
|
gint i = g_rand_int (dither_rand);
|
||||||
|
|
||||||
gradient_render_pixel (x, y, &color, rbd);
|
gradient_render_pixel (x, y, &color, rbd);
|
||||||
|
|
||||||
gradient_dither (dest, dither_rand, gimp_rgb_intensity (&color));
|
gray = gimp_rgb_intensity (&color);
|
||||||
gradient_dither (dest, dither_rand, color.a);
|
|
||||||
|
*dest++ = gray * 255.0 + (gdouble) (i & 0xff) / 256.0; i >>= 8;
|
||||||
|
*dest++ = color.a * 255.0 + (gdouble) (i & 0xff) / 256.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_rand_free (dither_rand);
|
g_rand_free (dither_rand);
|
||||||
|
|
Loading…
Reference in New Issue