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

Commit d4b3a8fa authored by James O'Leary's avatar James O'Leary
Browse files

Cache set wallpaper as PNG instead of JPEG

JPEG is a lossy image format: if image bytes are encoded to JPEG, then
the JPEG is decoded to image bytes, those bytes will _always_ differ
from the original bytes.

Caching as PNG ensures that the same colors will be extracted from the
wallpaper as were displayed in the Wallpaper Picker preview using
WallpaperColors.fromBitmap. Otherwise, the cached wallpaper differs from
the bitmap used with WallpaperColors.fromBitmap for the preview in
wallpaper picker.

Bug: 189931209
Test: Test tons and tons of wallpapers over a couple days.
Change-Id: I041d68bf057b24cf4dbd877ed403a1c2e67904dc
parent ecb8654a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -752,7 +752,7 @@ public class WallpaperManagerService extends IWallpaperManager.Stub

                        f = new FileOutputStream(wallpaper.cropFile);
                        bos = new BufferedOutputStream(f, 32*1024);
                        finalCrop.compress(Bitmap.CompressFormat.JPEG, 100, bos);
                        finalCrop.compress(Bitmap.CompressFormat.PNG, 100, bos);
                        bos.flush();  // don't rely on the implicit flush-at-close when noting success
                        success = true;
                    }