Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
mcychan authored Feb 6, 2025
1 parent 41f494b commit 590a3ea
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/nQuant/j2se/GilbertCurve.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ private GilbertCurve(final int width, final int height, final int[] pixels, fina
this.ditherable = ditherable;
this.saliencies = saliencies;
boolean hasAlpha = weight < 0;
sortedByYDiff = palette.length >= 128 && (hasAlpha ? weight < .18 : weight >= .052);
weight = Math.abs(weight);
margin = weight < .0025 ? 12 : weight < .004 ? 8 : 6;
sortedByYDiff = palette.length >= 128 && (hasAlpha ? weight < .18 : weight >= .052);
beta = palette.length > 8 ? palette.length > 24 ? .25f : .7f : 1;
if(palette.length > 64 || weight > .02)
beta *= .4f;
Expand All @@ -74,7 +74,7 @@ public int compare(ErrorBox o1, ErrorBox o2) {

DITHER_MAX = weight < .01 ? (weight > .0025) ? (byte) 25 : 16 : 9;
double edge = hasAlpha ? 1 : Math.exp(weight) - .25;
double deviation = weight > .0025 ? -.25 : 1;
double deviation = !hasAlpha && weight > .0025 ? -.25 : 1;
ditherMax = (hasAlpha || DITHER_MAX > 9) ? (byte) BitmapUtilities.sqr(Math.sqrt(DITHER_MAX) + edge * deviation) : DITHER_MAX;
final int density = palette.length > 16 ? 3200 : 1500;
if(palette.length / weight > 5000 && (weight > .045 || (weight > .01 && palette.length <= 64)))
Expand Down
2 changes: 1 addition & 1 deletion src/nQuant/j2se/PnnLABQuantizer.java
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ protected short[] dither(Color[] palette, int width, int height, boolean dither)
if(hasSemiTransparency)
weight *= -1;

if(dither && saliencies == null && weight < .052) {
if(dither && !hasSemiTransparency && saliencies == null && weight < .052) {
saliencies = new float[pixels.length];
float saliencyBase = .1f;

Expand Down

0 comments on commit 590a3ea

Please sign in to comment.