Fix Floyd-Steinberg error propagation for the 1/16 part

This patch fixes the quantization of a complete gray
image (RGB=128,128,128), which must generate a black and white
checkered pattern when the Floyd-Steinberg filter is applied.

Regression from b6d07d995f14e7559b1d92025e74f4ace166324e
This commit is contained in:
David Capello 2019-04-03 15:02:23 -03:00
parent 08ec3767ba
commit e1437a20c3

View File

@ -93,8 +93,7 @@ doc::color_t ErrorDiffusionDither::ditherRgbToIndex2D(
const int a = quantError[i] * 7 / 16;
const int b = quantError[i] * 3 / 16;
const int c = quantError[i] * 5 / 16;
// Same as d=quantError[i]*1/16 but without rounding errors
const int d = quantError[i] - a - b - c;
const int d = quantError[i] * 1 / 16;
if (y & 1) {
err[0 ] += a;