mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-04 09:53:25 +00:00
app: gimpoperationgradient keep achromatic colors under dither
Use the same amount of dithering on R,G and B if they initially were all equal. This allows us to keep achromatic gradients achromatic, while providing the same amount of dither as before for colored gradients. Discrepancy uncovered in issue #10756.
This commit is contained in:
parent
8e63ef91f5
commit
597c52b92e
1 changed files with 16 additions and 3 deletions
|
@ -1060,9 +1060,22 @@ gradient_dither_pixel (GimpRGB *color,
|
||||||
|
|
||||||
i = g_rand_int (dither_rand);
|
i = g_rand_int (dither_rand);
|
||||||
|
|
||||||
r = color->r + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0; i >>= 8;
|
if ((color->r == color->g) && (color->r == color->b))
|
||||||
g = color->g + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0; i >>= 8;
|
{
|
||||||
b = color->b + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0; i >>= 8;
|
gdouble dither = (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
||||||
|
r = color->r + dither;
|
||||||
|
g = color->g + dither;
|
||||||
|
b = color->b + dither;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
r = color->r + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
||||||
|
i >>= 8;
|
||||||
|
g = color->g + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
||||||
|
i >>= 8;
|
||||||
|
b = color->b + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
||||||
|
i >>= 8;
|
||||||
|
}
|
||||||
|
|
||||||
if (color->a > 0.0 && color->a < 1.0)
|
if (color->a > 0.0 && color->a < 1.0)
|
||||||
a = color->a + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
a = color->a + (gdouble) (i & 0xff) / 256.0 / 256.0 - 0.5 / 256.0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue