diff options
| author | 2023-05-01 18:31:31 +0000 | |
|---|---|---|
| committer | 2023-05-01 18:31:31 +0000 | |
| commit | e402bc94c320842d82129c46cb457dddf6ac4b04 (patch) | |
| tree | 5ceb619a53dcb974b58e664ab262ddda042cb60a | |
| parent | dc661b7ccbd8f4f1eb2a2f4104daa174d2940b98 (diff) | |
| parent | b86725295ad8e46de7cb2de0b759de0df3ac1e85 (diff) | |
Merge "Use less clusters for color extraction for small bitmaps" into udc-dev am: 8452c8833f am: e921fc5cc5 am: b86725295a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22930898
Change-Id: I04436182faedfe9677c1cec2d8d6c41fb1d5f822
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
| -rw-r--r-- | core/java/android/app/WallpaperColors.java | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java index a34a50c4b7b0..be1d8b8ad7d3 100644 --- a/core/java/android/app/WallpaperColors.java +++ b/core/java/android/app/WallpaperColors.java @@ -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(); } |