summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2013-04-18 18:43:29 -0700
committerJohn Hoford <hoford@google.com>2013-04-19 15:26:53 -0700
commit55afc2dcadf2f88774fbbe2eb7b11a5639b9fa29 (patch)
tree335ed4e00219d5cb86ce19fc45a5d38f603d4b4b /src/com/android/gallery3d/filtershow/filters
parent8d732159c1093e7ce970cb34bc6d36a14f26e3fa (diff)
downloadandroid_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')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java9
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java46
2 files changed, 21 insertions, 34 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
index 7b69ce9e0..ac5e04601 100644
--- a/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
+++ b/src/com/android/gallery3d/filtershow/filters/FilterTinyPlanetRepresentation.java
@@ -31,6 +31,7 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
setTextId(R.string.tinyplanet);
setButtonId(R.id.tinyplanetButton);
setEditorId(EditorTinyPlanet.ID);
+ setMinimum(1);
}
@Override
@@ -42,6 +43,14 @@ public class FilterTinyPlanetRepresentation extends FilterBasicRepresentation {
return representation;
}
+ @Override
+ public void useParametersFrom(FilterRepresentation a) {
+ FilterTinyPlanetRepresentation representation = (FilterTinyPlanetRepresentation) a;
+ super.useParametersFrom(a);
+ mAngle = representation.mAngle;
+ setZoom(representation.getZoom());
+ }
+
public void setAngle(float angle) {
mAngle = angle;
}
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;