diff options
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java')
-rw-r--r-- | src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java | 74 |
1 files changed, 42 insertions, 32 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java index 36bd62630..702cc664c 100644 --- a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java +++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java @@ -18,22 +18,26 @@ package com.android.gallery3d.filtershow.filters; import android.graphics.Bitmap; import android.graphics.Canvas; +import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.RectF; import com.adobe.xmp.XMPException; import com.adobe.xmp.XMPMeta; import com.android.gallery3d.R; import com.android.gallery3d.app.Log; +import com.android.gallery3d.filtershow.editors.EditorTinyPlanet; import com.android.gallery3d.filtershow.presets.ImagePreset; /** * An image filter which creates a tiny planet projection. */ -public class ImageFilterTinyPlanet extends ImageFilter { - private float mAngle = 0; +public class ImageFilterTinyPlanet extends SimpleImageFilter { - private static final String TAG = ImageFilterTinyPlanet.class.getSimpleName(); + + private static final String LOGTAG = ImageFilterTinyPlanet.class.getSimpleName(); public static final String GOOGLE_PANO_NAMESPACE = "http://ns.google.com/photos/1.0/panorama/"; + FilterTinyPlanetRepresentation mParameters = new FilterTinyPlanetRepresentation(); public static final String CROPPED_AREA_IMAGE_WIDTH_PIXELS = "CroppedAreaImageWidthPixels"; @@ -49,38 +53,18 @@ public class ImageFilterTinyPlanet extends ImageFilter { "CroppedAreaTopPixels"; public ImageFilterTinyPlanet() { - setFilterType(TYPE_TINYPLANET); mName = "TinyPlanet"; - - mMinParameter = 10; - mMaxParameter = 60; - mDefaultParameter = 20; - mPreviewParameter = 20; - mParameter = 20; - mAngle = 0; } @Override - public int getButtonId() { - return R.id.tinyplanetButton; + public void useRepresentation(FilterRepresentation representation) { + FilterTinyPlanetRepresentation parameters = (FilterTinyPlanetRepresentation) representation; + mParameters = parameters; } @Override - public int getTextId() { - return R.string.tinyplanet; - } - - public void setAngle(float angle) { - mAngle = angle; - } - - public float getAngle() { - return mAngle; - } - - public boolean isNil() { - // TinyPlanet always has an effect - return false; + public FilterRepresentation getDefaultRepresentation() { + return new FilterTinyPlanetRepresentation(); } native protected void nativeApplyFilter( @@ -88,7 +72,7 @@ public class ImageFilterTinyPlanet extends ImageFilter { float angle); @Override - public Bitmap apply(Bitmap bitmapIn, float scaleFactor, boolean highQuality) { + public Bitmap apply(Bitmap bitmapIn, float scaleFactor, int quality) { int w = bitmapIn.getWidth(); int h = bitmapIn.getHeight(); int outputSize = (int) (w / 2f); @@ -110,11 +94,38 @@ public class ImageFilterTinyPlanet extends ImageFilter { } catch (java.lang.OutOfMemoryError e) { System.gc(); outputSize /= 2; - Log.v(TAG, "No memory to create Full Tiny Planet create half"); + Log.v(LOGTAG, "No memory to create Full Tiny Planet create half"); } } nativeApplyFilter(bitmapIn, bitmapIn.getWidth(), bitmapIn.getHeight(), mBitmapOut, - outputSize, mParameter / 100f, mAngle); + 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; } @@ -143,7 +154,6 @@ public class ImageFilterTinyPlanet extends ImageFilter { } catch (java.lang.OutOfMemoryError e) { System.gc(); scale /= 2; - Log.v(TAG, "No memory to create Full Tiny Planet create half"); } } Canvas paddedCanvas = new Canvas(paddedBitmap); |