summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-04-28 23:51:09 (GMT)
committerSunny Goyal <sunnygoyal@google.com>2015-04-28 23:51:29 (GMT)
commit73a22a58ceb53411d48df7bbbeb966168b92850c (patch)
tree2f510e863cc90326fc39592914b0202eee1d66a6
parent559d90d0dafbac1d97a1e6f18062309831a25d51 (diff)
downloadandroid_packages_apps_Trebuchet-73a22a58ceb53411d48df7bbbeb966168b92850c.zip
android_packages_apps_Trebuchet-73a22a58ceb53411d48df7bbbeb966168b92850c.tar.gz
android_packages_apps_Trebuchet-73a22a58ceb53411d48df7bbbeb966168b92850c.tar.bz2
Using utility method for serializing bitmap
Change-Id: I066f40cf867326b0a116351f00b19350b4c26912
-rw-r--r--src/com/android/launcher3/LauncherBackupHelper.java24
1 files changed, 5 insertions, 19 deletions
diff --git a/src/com/android/launcher3/LauncherBackupHelper.java b/src/com/android/launcher3/LauncherBackupHelper.java
index 064f436..92bbb40 100644
--- a/src/com/android/launcher3/LauncherBackupHelper.java
+++ b/src/com/android/launcher3/LauncherBackupHelper.java
@@ -88,11 +88,6 @@ public class LauncherBackupHelper implements BackupHelper {
/** widgets contain previews, which are very large, dribble them out */
private static final int MAX_WIDGETS_PER_PASS = 5;
- private static final int IMAGE_COMPRESSION_QUALITY = 75;
-
- private static final Bitmap.CompressFormat IMAGE_FORMAT =
- android.graphics.Bitmap.CompressFormat.PNG;
-
private static final String[] FAVORITE_PROJECTION = {
Favorites._ID, // 0
Favorites.MODIFIED, // 1
@@ -969,10 +964,7 @@ public class LauncherBackupHelper implements BackupHelper {
private Resource packIcon(int dpi, Bitmap icon) {
Resource res = new Resource();
res.dpi = dpi;
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (icon.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
- res.data = os.toByteArray();
- }
+ res.data = Utilities.flattenBitmap(icon);
return res;
}
@@ -990,20 +982,14 @@ public class LauncherBackupHelper implements BackupHelper {
widget.icon = new Resource();
Drawable fullResIcon = iconCache.getFullResIcon(provider.getPackageName(), info.icon);
Bitmap icon = Utilities.createIconBitmap(fullResIcon, mContext);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (icon.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
- widget.icon.data = os.toByteArray();
- widget.icon.dpi = dpi;
- }
+ widget.icon.data = Utilities.flattenBitmap(icon);
+ widget.icon.dpi = dpi;
}
if (info.previewImage != 0) {
widget.preview = new Resource();
Bitmap preview = previewLoader.generateWidgetPreview(info, previewWidth, null);
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- if (preview.compress(IMAGE_FORMAT, IMAGE_COMPRESSION_QUALITY, os)) {
- widget.preview.data = os.toByteArray();
- widget.preview.dpi = dpi;
- }
+ widget.preview.data = Utilities.flattenBitmap(preview);
+ widget.preview.dpi = dpi;
}
return widget;
}