Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 211fe45b authored by Automerger Merge Worker's avatar Automerger Merge Worker Committed by Android (Google) Code Review
Browse files

Merge "Merge "Use less clusters for color extraction for small bitmaps" into...

Merge "Merge "Use less clusters for color extraction for small bitmaps" into udc-dev am: 8452c883 am: e921fc5c am: b8672529" into udc-qpr-dev-plus-aosp
parents 7ffdb6a1 e402bc94
Loading
Loading
Loading
Loading
+9 −1
Original line number Diff line number Diff line
@@ -213,9 +213,17 @@ public final class WallpaperColors implements Parcelable {
                    .resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
                    .generate();
        } else {
            // in any case, always use between 5 and 128 clusters
            int minClusters = 5;
            int maxClusters = 128;

            // if the bitmap is very small, use bitmapArea/16 clusters instead of 128
            int minPixelsPerCluster = 16;
            int numberOfColors = Math.max(minClusters,
                    Math.min(maxClusters, bitmapArea / minPixelsPerCluster));
            palette = Palette
                    .from(bitmap, new CelebiQuantizer())
                    .maximumColorCount(128)
                    .maximumColorCount(numberOfColors)
                    .resizeBitmapArea(MAX_WALLPAPER_EXTRACTION_AREA)
                    .generate();
        }