Fix crash when quantizing

Incoming pixels are negative numbers. Performing this operation
ensures we receive an accurate alpha value, without it, all pixels have negative alphas.

Fixes: 182523380
Test: Add logs, see that alphas _before_ this patch are logged
as negative numbers, causing all pixels to be marked as transparent and ignored in quantization. Add patch, see logs
indicate valid alphas.

Change-Id: Ice7b7db245de9dd089cffc490b2e24780f9c025b
This commit is contained in:
James O'Leary
2021-03-12 13:30:22 -05:00
parent c22a378048
commit 14c6e6fcf5

View File

@@ -75,7 +75,7 @@ public class WSMeansQuantizer implements Quantizer {
// Note: they don't _have_ to be ignored, for example, we could instead turn them
// opaque. Traditionally, including outside Android, quantizers ignore transparent
// pixels, so that strategy was chosen.
int alpha = (pixel >> 24);
int alpha = (pixel >> 24) & 0xff;
if (alpha < 255) {
continue;
}