summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSascha Haeberling <haeberling@google.com>2012-10-18 00:36:02 -0700
committerSascha Haeberling <haeberling@google.com>2012-10-18 14:29:29 -0700
commit079ee7776fb81d1f38ea22bf553d2c7c9ba45103 (patch)
treeac30bf1c1ff02f7a452cec17066769df807f2563 /src
parentf6c31e476d940a8306a7e14ad47215a87540dbf0 (diff)
downloadandroid_packages_apps_Snap-079ee7776fb81d1f38ea22bf553d2c7c9ba45103.tar.gz
android_packages_apps_Snap-079ee7776fb81d1f38ea22bf553d2c7c9ba45103.tar.bz2
android_packages_apps_Snap-079ee7776fb81d1f38ea22bf553d2c7c9ba45103.zip
First cut at a skeleton for the TinyPlanets filter.
Bug: 7344426 This is not hooking up the real algorithm yet, but unblocks Doris so she can add the button while we rewrite the algorithm. Change-Id: I685b6c189e8ac124670db53c37565c4f1ff1f606
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/app/PhotoPage.java2
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java5
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java12
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java1
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java36
5 files changed, 54 insertions, 2 deletions
diff --git a/src/com/android/gallery3d/app/PhotoPage.java b/src/com/android/gallery3d/app/PhotoPage.java
index ecb48329a..a548e704f 100644
--- a/src/com/android/gallery3d/app/PhotoPage.java
+++ b/src/com/android/gallery3d/app/PhotoPage.java
@@ -59,7 +59,6 @@ import com.android.gallery3d.data.SnailItem;
import com.android.gallery3d.data.SnailSource;
import com.android.gallery3d.filtershow.FilterShowActivity;
import com.android.gallery3d.picasasource.PicasaSource;
-import com.android.gallery3d.ui.AnimationTime;
import com.android.gallery3d.ui.DetailsHelper;
import com.android.gallery3d.ui.DetailsHelper.CloseListener;
import com.android.gallery3d.ui.DetailsHelper.DetailsSource;
@@ -73,7 +72,6 @@ import com.android.gallery3d.ui.PhotoFallbackEffect;
import com.android.gallery3d.ui.PhotoView;
import com.android.gallery3d.ui.SelectionManager;
import com.android.gallery3d.ui.SynchronizedHandler;
-import com.android.gallery3d.ui.TiledScreenNail;
import com.android.gallery3d.util.GalleryUtils;
public class PhotoPage extends ActivityState implements
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index fa9277ebe..02551ee4d 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -47,6 +47,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterParametricBorder;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
import com.android.gallery3d.filtershow.filters.ImageFilterShadows;
+import com.android.gallery3d.filtershow.filters.ImageFilterTinyPlanet;
import com.android.gallery3d.filtershow.filters.ImageFilterVibrance;
import com.android.gallery3d.filtershow.filters.ImageFilterVignette;
import com.android.gallery3d.filtershow.filters.ImageFilterWBalance;
@@ -229,16 +230,19 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
mPanelController.addPanel(mColorsButton, mListColors, 3);
int[] recastIDs = {
+ R.id.tinyplanetButton,
R.id.vignetteButton,
R.id.vibranceButton,
R.id.contrastButton,
R.id.saturationButton,
+ R.id.shadowRecoveryButton,
R.id.wbalanceButton,
R.id.hueButton,
R.id.exposureButton,
R.id.shadowRecoveryButton
};
ImageFilter[] filters = {
+ new ImageFilterTinyPlanet(),
new ImageFilterVignette(),
new ImageFilterVibrance(),
new ImageFilterContrast(),
@@ -304,6 +308,7 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
listColors.addView(fView, pos);
}
+ mPanelController.addComponent(mColorsButton, findViewById(R.id.tinyplanetButton));
mPanelController.addComponent(mColorsButton, findViewById(R.id.curvesButtonRGB));
mPanelController.addComponent(mColorsButton, findViewById(R.id.sharpenButton));
mPanelController.addComponent(mColorsButton, findViewById(R.id.vibranceButton));
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index b0f38892b..6c28fce57 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -17,6 +17,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
import com.android.gallery3d.filtershow.filters.ImageFilterShadows;
import com.android.gallery3d.filtershow.filters.ImageFilterSharpen;
+import com.android.gallery3d.filtershow.filters.ImageFilterTinyPlanet;
import com.android.gallery3d.filtershow.filters.ImageFilterVibrance;
import com.android.gallery3d.filtershow.filters.ImageFilterVignette;
import com.android.gallery3d.filtershow.filters.ImageFilterWBalance;
@@ -435,6 +436,10 @@ public class PanelController implements OnClickListener {
public void ensureFilter(String name) {
ImagePreset preset = getImagePreset();
ImageFilter filter = preset.getFilter(name);
+ if (filter == null && name.equalsIgnoreCase(
+ mCurrentImage.getContext().getString(R.string.tinyplanet))) {
+ filter = setImagePreset(new ImageFilterTinyPlanet(), name);
+ }
if (filter == null
&& name.equalsIgnoreCase(mCurrentImage.getContext().getString(R.string.vignette))) {
filter = setImagePreset(new ImageFilterVignette(), name);
@@ -501,6 +506,13 @@ public class PanelController implements OnClickListener {
}
mUtilityPanel.hideAspectButtons();
switch (view.getId()) {
+ case R.id.tinyplanetButton: {
+ mCurrentImage = showImageView(R.id.imageShow).setShowControls(true);
+ String ename = mCurrentImage.getContext().getString(R.string.tinyplanet);
+ mUtilityPanel.setEffectName(ename);
+ ensureFilter(ename);
+ break;
+ }
case R.id.straightenButton: {
mCurrentImage = showImageView(R.id.imageStraighten);
String ename = mCurrentImage.getContext().getString(R.string.straighten);
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 78a835130..270eb9a46 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -16,6 +16,7 @@ public class ImageFilter implements Cloneable {
public static final byte TYPE_WBALANCE = 3;
public static final byte TYPE_VIGNETTE = 4;
public static final byte TYPE_NORMAL = 5;
+ public static final byte TYPE_TINYPLANET = 6;
private byte filterType = TYPE_NORMAL;
public byte getFilterType(){
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
new file mode 100644
index 000000000..25751052c
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterTinyPlanet.java
@@ -0,0 +1,36 @@
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Paint.Align;
+import android.util.Log;
+
+public class ImageFilterTinyPlanet extends ImageFilter {
+ private static final String TAG = ImageFilterTinyPlanet.class.getSimpleName();
+
+ public ImageFilterTinyPlanet() {
+ setFilterType(TYPE_TINYPLANET);
+ mName = "TinyPlanet";
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ Log.d(TAG, "Applying tiny planet.");
+
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+
+ // Print TinyPlanet as text on the image as a placeholder
+ // TODO(haeberling): Implement the real deal.
+ Canvas canvas = new Canvas(bitmap);
+ Paint paint = new Paint();
+ paint.setColor(Color.RED);
+ paint.setTextSize((int) (((mParameter + 100) / 200f) * 100));
+ paint.setTextAlign(Align.CENTER);
+ canvas.drawText("TinyPlanet", w / 2, h / 2, paint);
+ return super.apply(bitmap, scaleFactor, highQuality);
+ }
+}