summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2012-10-24 12:56:31 -0700
committerJohn Reck <jreck@google.com>2012-10-24 14:08:24 -0700
commit80a35b17989ee57b706cd18cfe8c5d928f08eeda (patch)
tree34b2318b822ea3d924594e86bccabef26aecd71c /src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
parent474cf37aca1a88f909cc272ab5f7936726c011ab (diff)
downloadandroid_packages_apps_Snap-80a35b17989ee57b706cd18cfe8c5d928f08eeda.tar.gz
android_packages_apps_Snap-80a35b17989ee57b706cd18cfe8c5d928f08eeda.tar.bz2
android_packages_apps_Snap-80a35b17989ee57b706cd18cfe8c5d928f08eeda.zip
Move loadBitmap to async task
Bug: 7406705 Change-Id: I4e540e08d239d2e57f0ae6be5d70c8777cdbab2a
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java66
1 files changed, 35 insertions, 31 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
index c996e9c03..003d036e0 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
@@ -66,37 +66,8 @@ public class ImageFilterTinyPlanet extends ImageFilter {
int outputSize = Math.min(w, h);
ImagePreset preset = getImagePreset();
- if (preset != null) {
- if (preset.isPanoramaSafe()) {
- try {
- XMPMeta xmp = preset.getImageLoader().getXmpObject();
- int croppedAreaWidth =
- getInt(xmp, CROPPED_AREA_IMAGE_WIDTH_PIXELS);
- int croppedAreaHeight =
- getInt(xmp, CROPPED_AREA_IMAGE_HEIGHT_PIXELS);
- int fullPanoWidth =
- getInt(xmp, CROPPED_AREA_FULL_PANO_WIDTH_PIXELS);
- int fullPanoHeight =
- getInt(xmp, CROPPED_AREA_FULL_PANO_HEIGHT_PIXELS);
- int left = getInt(xmp, CROPPED_AREA_LEFT);
- int top = getInt(xmp, CROPPED_AREA_TOP);
-
- Bitmap paddedBitmap = Bitmap.createBitmap(
- fullPanoWidth, fullPanoHeight, Bitmap.Config.ARGB_8888);
- Canvas paddedCanvas = new Canvas(paddedBitmap);
-
- int right = left + croppedAreaWidth;
- int bottom = top + croppedAreaHeight;
- Rect destRect = new Rect(left, top, right, bottom);
- paddedCanvas.drawBitmap(bitmapIn, null, destRect, null);
- bitmapIn = paddedBitmap;
- } catch (XMPException ex) {
- // Do nothing, just use bitmapIn as is.
- }
- } else {
- // Do nothing, just use bitmapIn as is, there is nothing else we
- // can do.
- }
+ if (preset != null && preset.isPanoramaSafe()) {
+ bitmapIn = applyXmp(bitmapIn, preset);
}
Bitmap mBitmapOut = Bitmap.createBitmap(
@@ -106,6 +77,39 @@ public class ImageFilterTinyPlanet extends ImageFilter {
return mBitmapOut;
}
+ private Bitmap applyXmp(Bitmap bitmapIn, ImagePreset preset) {
+ try {
+ XMPMeta xmp = preset.getImageLoader().getXmpObject();
+ if (xmp == null) {
+ // Do nothing, just use bitmapIn as is.
+ return bitmapIn;
+ }
+ int croppedAreaWidth =
+ getInt(xmp, CROPPED_AREA_IMAGE_WIDTH_PIXELS);
+ int croppedAreaHeight =
+ getInt(xmp, CROPPED_AREA_IMAGE_HEIGHT_PIXELS);
+ int fullPanoWidth =
+ getInt(xmp, CROPPED_AREA_FULL_PANO_WIDTH_PIXELS);
+ int fullPanoHeight =
+ getInt(xmp, CROPPED_AREA_FULL_PANO_HEIGHT_PIXELS);
+ int left = getInt(xmp, CROPPED_AREA_LEFT);
+ int top = getInt(xmp, CROPPED_AREA_TOP);
+
+ Bitmap paddedBitmap = Bitmap.createBitmap(
+ fullPanoWidth, fullPanoHeight, Bitmap.Config.ARGB_8888);
+ Canvas paddedCanvas = new Canvas(paddedBitmap);
+
+ int right = left + croppedAreaWidth;
+ int bottom = top + croppedAreaHeight;
+ Rect destRect = new Rect(left, top, right, bottom);
+ paddedCanvas.drawBitmap(bitmapIn, null, destRect, null);
+ bitmapIn = paddedBitmap;
+ } catch (XMPException ex) {
+ // Do nothing, just use bitmapIn as is.
+ }
+ return bitmapIn;
+ }
+
private static int getInt(XMPMeta xmp, String key) throws XMPException {
if (xmp.doesPropertyExist(GOOGLE_PANO_NAMESPACE, key)) {
return xmp.getPropertyInteger(GOOGLE_PANO_NAMESPACE, key);