Skip to content

Commit e77ff19

Browse files
authored
Add files via upload
1 parent b13211e commit e77ff19

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

nQuant.Master/GilbertCurve.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ internal int Length
5454
private readonly Ditherable ditherable;
5555
private readonly float[] saliencies;
5656
private List<ErrorBox> errorq;
57-
private readonly int[] lookup;
5857

5958
private readonly int margin, thresold;
6059
private const float BLOCK_SIZE = 343f;
@@ -107,7 +106,6 @@ private GilbertCurve(int width, int height, int[] pixels, Color[] palette, int[]
107106
ditherMax = (byte) BitmapUtilities.Sqr(5 + edge);
108107
thresold = DITHER_MAX > 9 ? -112 : -64;
109108
weights = new float[0];
110-
lookup = new int[65536];
111109
}
112110

113111

@@ -181,10 +179,7 @@ private int DitherPixel(int x, int y, Color c2, float beta)
181179
if (beta > 1f && CIELABConvertor.Y_Diff(pixel, c2) > DITHER_MAX)
182180
c2 = Color.FromArgb(a_pix, r_pix, g_pix, b_pix);
183181

184-
int offset = ditherable.GetColorIndex(c2.ToArgb());
185-
if (lookup[offset] == 0)
186-
lookup[offset] = ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx) + 1;
187-
return lookup[offset] - 1;
182+
return ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx);
188183
}
189184

190185
private void DiffusePixel(int x, int y)
@@ -223,10 +218,7 @@ private void DiffusePixel(int x, int y)
223218
}
224219
else if (palette.Length <= 32 && a_pix > 0xF0)
225220
{
226-
int offset = ditherable.GetColorIndex(c2.ToArgb());
227-
if (lookup[offset] == 0)
228-
lookup[offset] = ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx) + 1;
229-
qPixels[bidx] = lookup[offset] - 1;
221+
qPixels[bidx] = ditherable.DitherColorIndex(palette, c2.ToArgb(), bidx);
230222

231223
int acceptedDiff = Math.Max(2, palette.Length - margin);
232224
if (saliencies != null && (CIELABConvertor.Y_Diff(pixel, c2) > acceptedDiff || CIELABConvertor.U_Diff(pixel, c2) > (2 * acceptedDiff)))

0 commit comments

Comments
 (0)