Merge changes Ic9dc1fe3,I1ca71ccf into sc-dev
* changes:
Ensure wallpaper isn't cropped unnecessarily
Compress wallpaper to PNG instead of JPEG when setting wallpaper
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
index 0060f99..bf86585 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
@@ -484,7 +484,7 @@
private int setBitmapToWallpaperManagerCompat(Bitmap wallpaperBitmap, boolean allowBackup,
int whichWallpaper) {
ByteArrayOutputStream tmpOut = new ByteArrayOutputStream();
- if (wallpaperBitmap.compress(CompressFormat.JPEG, DEFAULT_COMPRESS_QUALITY, tmpOut)) {
+ if (wallpaperBitmap.compress(CompressFormat.PNG, DEFAULT_COMPRESS_QUALITY, tmpOut)) {
try {
byte[] outByteArray = tmpOut.toByteArray();
return mWallpaperManagerCompat.setStream(
diff --git a/src/com/android/wallpaper/util/WallpaperCropUtils.java b/src/com/android/wallpaper/util/WallpaperCropUtils.java
index bff7a67..eaf0e4a 100755
--- a/src/com/android/wallpaper/util/WallpaperCropUtils.java
+++ b/src/com/android/wallpaper/util/WallpaperCropUtils.java
@@ -193,8 +193,8 @@
public static Rect calculateCropRect(Context context, float wallpaperZoom, Point wallpaperSize,
Point defaultCropSurfaceSize, Point targetHostSize, int scrollX, int scrollY) {
// Calculate Rect of wallpaper in physical pixel terms (i.e., scaled to current zoom).
- int scaledWallpaperWidth = (int) (wallpaperSize.x * wallpaperZoom);
- int scaledWallpaperHeight = (int) (wallpaperSize.y * wallpaperZoom);
+ int scaledWallpaperWidth = Math.round(wallpaperSize.x * wallpaperZoom);
+ int scaledWallpaperHeight = Math.round(wallpaperSize.y * wallpaperZoom);
Rect rect = new Rect();
rect.set(0, 0, scaledWallpaperWidth, scaledWallpaperHeight);