summaryrefslogtreecommitdiffstats
path: root/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
diff options
context:
space:
mode:
authornicolasroard <nicolasroard@google.com>2013-01-28 16:36:46 -0800
committernicolasroard <nicolasroard@google.com>2013-02-05 00:03:18 -0800
commitda4de5aa86b49be455efe396455b77be44dec684 (patch)
tree4d35214fecb7af9f2f09cd44b4910cf793d2af6d /src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
parent465e25bd3cb2c76732102d7be98bc0335962f715 (diff)
downloadandroid_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.tar.gz
android_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.tar.bz2
android_packages_apps_Snap-da4de5aa86b49be455efe396455b77be44dec684.zip
Refactor filters parameters
- introduce FilterRepresentations - change filters lifecycle Change-Id: I9416fca47a334d532a347cd5577795738c870933
Diffstat (limited to 'src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java')
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
index 784028a8d..c2b648110 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
@@ -23,20 +23,27 @@ import android.graphics.Rect;
import com.android.gallery3d.R;
import com.android.gallery3d.filtershow.cache.ImageLoader;
-public class ImageFilterDownsample extends ImageFilter {
+public class ImageFilterDownsample extends SimpleImageFilter {
private static final int ICON_DOWNSAMPLE_FRACTION = 8;
private ImageLoader mImageLoader;
public ImageFilterDownsample(ImageLoader loader) {
mName = "Downsample";
- mMaxParameter = 100;
- mMinParameter = 1;
- mPreviewParameter = 3;
- mDefaultParameter = 50;
- mParameter = 50;
mImageLoader = loader;
}
+ public FilterRepresentation getDefaultRepresentation() {
+ FilterBasicRepresentation representation = (FilterBasicRepresentation) super.getDefaultRepresentation();
+ representation.setName("Downsample");
+ representation.setFilterClass(ImageFilterDownsample.class);
+ representation.setMaximum(100);
+ representation.setMinimum(1);
+ representation.setValue(50);
+ representation.setDefaultValue(50);
+ representation.setPreviewValue(3);
+ return representation;
+ }
+
@Override
public int getButtonId() {
return R.id.downsampleButton;
@@ -48,15 +55,13 @@ public class ImageFilterDownsample extends ImageFilter {
}
@Override
- public boolean isNil() {
- return false;
- }
-
- @Override
public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ if (getParameters() == null) {
+ return bitmap;
+ }
int w = bitmap.getWidth();
int h = bitmap.getHeight();
- int p = mParameter;
+ int p = getParameters().getValue();
// size of original precached image
Rect size = mImageLoader.getOriginalBounds();