Skip to content

Commit

Permalink
Update GilbertCurve.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Jan 18, 2023
1 parent 2b27581 commit bff2adc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions nQuant.Master/GilbertCurve.cs
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,14 @@ private void DitherPixel(int x, int y)
error[2] = b_pix - c2.B;
error[3] = a_pix - c2.A;

var dither = (palette.Length < 3 || DIVISOR < 2) ? false : true;
var diffuse = DIVISOR > 2 && BlueNoise.RAW_BLUE_NOISE[bidx & 4095] > -88;

for (int j = 0; j < error.Length; ++j)
{
var diffuse = (palette.Length < 3 || DIVISOR < 2) ? false : true;
if (Math.Abs(error[j]) >= DITHER_MAX && diffuse)
{
if (Math.Abs(error[j]) >= DITHER_MAX && dither)
{
if (saliencies != null || (DIVISOR > 2 && BlueNoise.RAW_BLUE_NOISE[bidx & 4095] > -88))
if (diffuse)
error[j] = (float)Math.Tanh(error[j] / maxErr * 20) * (DITHER_MAX - 1);
else
error[j] /= DIVISOR;
Expand Down

0 comments on commit bff2adc

Please sign in to comment.