diff options
author | John Hoford <hoford@google.com> | 2013-04-18 18:43:29 -0700 |
---|---|---|
committer | John Hoford <hoford@google.com> | 2013-04-19 15:26:53 -0700 |
commit | 55afc2dcadf2f88774fbbe2eb7b11a5639b9fa29 (patch) | |
tree | 335ed4e00219d5cb86ce19fc45a5d38f603d4b4b /src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java | |
parent | 8d732159c1093e7ce970cb34bc6d36a14f26e3fa (diff) | |
download | android_packages_apps_Snap-55afc2dcadf2f88774fbbe2eb7b11a5639b9fa29.tar.gz android_packages_apps_Snap-55afc2dcadf2f88774fbbe2eb7b11a5639b9fa29.tar.bz2 android_packages_apps_Snap-55afc2dcadf2f88774fbbe2eb7b11a5639b9fa29.zip |
tiny planet fix
bug:8323524
Change-Id: I39283face7079574dbe25e797323a84141930f9a
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java | 46 |
1 files changed, 12 insertions, 34 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java index 9874deaaf..37d5739a0 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java @@ -65,30 +65,34 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter { return new FilterTinyPlanetRepresentation(); } + native protected void nativeApplyFilter( Bitmap bitmapIn, int width, int height, Bitmap bitmapOut, int outSize, float scale, float angle); + @Override public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) { int w = bitmapIn.getWidth(); int h = bitmapIn.getHeight(); int outputSize = (int) (w / 2f); ImagePreset preset = getImagePreset(); - + Bitmap mBitmapOut = null; if (preset != null) { XMPMeta xmp = preset.getImageLoader().getXmpObject(); // Do nothing, just use bitmapIn as is if we don't have XMP. if(xmp != null) { - bitmapIn = applyXmp(bitmapIn, xmp, w); + bitmapIn = applyXmp(bitmapIn, xmp, w); + } + } + if (mBitmapOut != null) { + if (outputSize != mBitmapOut.getHeight()) { + mBitmapOut = null; } } - - Bitmap mBitmapOut = null; while (mBitmapOut == null) { try { - mBitmapOut = Bitmap.createBitmap( - outputSize, outputSize, Bitmap.Config.ARGB_8888); + mBitmapOut = getEnvironment().getBitmap(outputSize, outputSize); } catch (java.lang.OutOfMemoryError e) { System.gc(); outputSize /= 2; @@ -98,32 +102,6 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter { nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut, outputSize, mParameters.getZoom() / 100f, mParameters.getAngle()); - if (true) { - // TODO(hoford): FIXME and remove this section - String text = "Tiny Planet Not Working"; - int w2 = bitmapIn.getWidth() / 2; - int h2 = bitmapIn.getHeight() / 2; - Canvas c = new Canvas(bitmapIn); - Paint p = new Paint(); - Rect src = new Rect(0, 0, mBitmapOut.getWidth(), mBitmapOut.getHeight()); - Rect dst = new Rect(0, 0, bitmapIn.getWidth(), bitmapIn.getHeight()); - c.drawBitmap(mBitmapOut, 0, 0, p); - float size = Math.min(w2, h2) / 4f; - p.setTextSize(size); - p.setColor(0xFF000000); - p.setStyle(Paint.Style.STROKE); - p.setStrokeWidth(20); - Rect bounds = new Rect(); - p.getTextBounds(text, 0, text.length(), bounds); - int tw = bounds.width() / 2; - c.drawText(text, w2 - tw, h2, p); - - p.setColor(0xFFFF0000); - p.setStyle(Paint.Style.FILL); - p.setStrokeWidth(0); - - c.drawText(text, w2 - tw, h2, p); - } return mBitmapOut; } @@ -150,8 +128,8 @@ public class ImageFilterTinyPlanet extends SimpleImageFilter { while (paddedBitmap == null) { try { paddedBitmap = Bitmap.createBitmap( - (int) (fullPanoWidth * scale), (int) (fullPanoHeight * scale), - Bitmap.Config.ARGB_8888); + (int) (fullPanoWidth * scale), (int) (fullPanoHeight * scale), + Bitmap.Config.ARGB_8888); } catch (java.lang.OutOfMemoryError e) { System.gc(); scale /= 2; |