From fbbb5dd5cade7c9f775bff25a20dbc99ec74303e Mon Sep 17 00:00:00 2001 From: James O'Leary Date: Thu, 11 Mar 2021 11:41:35 -0500 Subject: [PATCH] Fix create colors in Wu quantizer This line is suspiciously complicated compared to other 3 ints -> int representing color functions. This patch ensures the colors produced have an explicitly opaque alpha channel (transparent pixels are filtered out earlier in the quantization process), and ensures we're not unnecessarily masking the red/green/blue channels. Test: Add log dump to output hex for all colors created, immediately after the Wu quantization finishes, thus isolating it from the larger quantization process. Test a variety of wallpapers, make sure hex codes make sense, verify that the fix holds by converting Bug: 182333325 Change-Id: Ic0bd4afcd095845e00eb6d10d05aab336266d6c3 --- .../java/com/android/internal/graphics/palette/WuQuantizer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/com/android/internal/graphics/palette/WuQuantizer.java b/core/java/com/android/internal/graphics/palette/WuQuantizer.java index 66206bf8297a4..6d08dc88cb20e 100644 --- a/core/java/com/android/internal/graphics/palette/WuQuantizer.java +++ b/core/java/com/android/internal/graphics/palette/WuQuantizer.java @@ -129,7 +129,7 @@ public class WuQuantizer implements Quantizer { red = (int) (getVolume(cube[k], mMr) / weight); green = (int) (getVolume(cube[k], mMg) / weight); blue = (int) (getVolume(cube[k], mMb) / weight); - colors[k] = ((red & 0x0ff) << 16) | ((green & 0x0ff) << 8) | (blue & 0x0ff); + colors[k] = (255 << 24) | (red << 16) | (green << 8) | blue; } else { colors[k] = 0; }