diff options
| author | Sascha Haeberling <haeberling@google.com> | 2012-10-18 00:36:02 -0700 |
|---|---|---|
| committer | Sascha Haeberling <haeberling@google.com> | 2012-10-18 14:29:29 -0700 |
| commit | 2576a29cccf1d96edeef071914e8b775c230e8e8 (patch) | |
| tree | 4eb7c8a9ac35f9dbeaa78ad62ebd05bf6f0cb4c5 | |
| parent | 08e6b8650dfb11e282cca22da71750bcb2e5e478 (diff) | |
| download | android_packages_apps_Gallery2-2576a29cccf1d96edeef071914e8b775c230e8e8.tar.gz android_packages_apps_Gallery2-2576a29cccf1d96edeef071914e8b775c230e8e8.tar.bz2 android_packages_apps_Gallery2-2576a29cccf1d96edeef071914e8b775c230e8e8.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
7 files changed, 61 insertions, 2 deletions
diff --git a/res/layout/filtershow_activity.xml b/res/layout/filtershow_activity.xml index 78fe2d8b6..c62e7142b 100644 --- a/res/layout/filtershow_activity.xml +++ b/res/layout/filtershow_activity.xml @@ -317,6 +317,11 @@ android:layout_height="wrap_content" android:layout_marginLeft="@dimen/thumbnail_margin" android:orientation="horizontal" > + <com.android.gallery3d.filtershow.ui.ImageButtonTitle + android:id="@+id/tinyplanetButton" + style="@style/FilterShowBottomButton" + android:src="@drawable/filtershow_button_colors_contrast" + android:text="@string/tinyplanet" /> <com.android.gallery3d.filtershow.ui.ImageButtonTitle android:id="@+id/wbalanceButton" diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml index d4d02f597..a312f5afe 100644 --- a/res/values/filtershow_strings.xml +++ b/res/values/filtershow_strings.xml @@ -77,6 +77,8 @@ <string name="aspectNone_effect">None</string> <!-- Label for the aspect None effect [CHAR LIMIT=15] --> <string name="aspectOriginal_effect">Original</string> + <!-- Label for the tuny planet effect [CHAR LIMIT=10] --> + <string name="tinyplanet">Tiny Planet</string> <!-- Filters buttons --> 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); + } +} |
