summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java12
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java37
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java37
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java37
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java37
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java68
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageShow.java43
-rw-r--r--src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java4
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java33
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java33
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java33
-rw-r--r--src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java33
13 files changed, 86 insertions, 325 deletions
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index 161321904..079e5b18c 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -61,6 +61,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterBorder;
import com.android.gallery3d.filtershow.filters.ImageFilterBwFilter;
import com.android.gallery3d.filtershow.filters.ImageFilterContrast;
import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
+import com.android.gallery3d.filtershow.filters.ImageFilterDownsample;
import com.android.gallery3d.filtershow.filters.ImageFilterEdge;
import com.android.gallery3d.filtershow.filters.ImageFilterExposure;
import com.android.gallery3d.filtershow.filters.ImageFilterFx;
@@ -313,7 +314,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
new ImageFilterBwFilter(),
new ImageFilterNegative(),
new ImageFilterEdge(),
- new ImageFilterKMeans()
+ new ImageFilterKMeans(),
+ new ImageFilterDownsample()
};
for (int i = 0; i < filters.length; i++) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 2319fcc12..b8f0cf84f 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -23,11 +23,15 @@ import com.android.gallery3d.filtershow.presets.ImagePreset;
public class ImageFilter implements Cloneable {
- protected int mMaxParameter = 100;
- protected int mMinParameter = -100;
+ public static int DEFAULT_MAX_PARAMETER = 100;
+ public static int DEFAULT_MIN_PARAMETER = -100;
+ public static int DEFAULT_INITIAL_PARAMETER = 0;
+
+ protected int mMaxParameter = DEFAULT_MAX_PARAMETER;
+ protected int mMinParameter = DEFAULT_MIN_PARAMETER;
protected int mPreviewParameter = mMaxParameter;
- protected int mDefaultParameter = 0;
- protected int mParameter = 0;
+ protected int mDefaultParameter = DEFAULT_INITIAL_PARAMETER;
+ protected int mParameter = DEFAULT_INITIAL_PARAMETER;
private ImagePreset mImagePreset;
protected String mName = "Original";
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java
deleted file mode 100644
index f4a7717f9..000000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBW.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-
-public class ImageFilterBW extends ImageFilter {
-
- public ImageFilterBW() {
- mName = "Black & White";
- }
-
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- nativeApplyFilter(bitmap, w, h);
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java
deleted file mode 100644
index 45f49164b..000000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWBlue.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-
-public class ImageFilterBWBlue extends ImageFilter {
-
- public ImageFilterBWBlue() {
- mName = "B&W - Blue";
- }
-
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- nativeApplyFilter(bitmap, w, h);
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java
deleted file mode 100644
index 8f91c3c82..000000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWGreen.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-
-public class ImageFilterBWGreen extends ImageFilter {
-
- public ImageFilterBWGreen() {
- mName = "B&W - Green";
- }
-
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- nativeApplyFilter(bitmap, w, h);
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java
deleted file mode 100644
index f0c65d71e..000000000
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterBWRed.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.filters;
-
-import android.graphics.Bitmap;
-
-public class ImageFilterBWRed extends ImageFilter {
-
- public ImageFilterBWRed() {
- mName = "B&W - Red";
- }
-
- native protected void nativeApplyFilter(Bitmap bitmap, int w, int h);
-
- @Override
- public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
- int w = bitmap.getWidth();
- int h = bitmap.getHeight();
- nativeApplyFilter(bitmap, w, h);
- return bitmap;
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
new file mode 100644
index 000000000..fa2293ca7
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterDownsample.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+public class ImageFilterDownsample extends ImageFilter {
+
+ public ImageFilterDownsample() {
+ mName = "Downsample";
+ mMaxParameter = 100;
+ mMinParameter = 5;
+ mPreviewParameter = 10;
+ mDefaultParameter = 50;
+ mParameter = 50;
+ }
+
+ @Override
+ public int getButtonId() {
+ return R.id.downsampleButton;
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.downsample;
+ }
+
+ @Override
+ public boolean isNil() {
+ return false;
+ }
+
+ @Override
+ public Bitmap apply(Bitmap bitmap, float scaleFactor, boolean highQuality) {
+ int w = bitmap.getWidth();
+ int h = bitmap.getHeight();
+ int p = mParameter;
+ if (p > 0 && p < 100) {
+ int newWidth = w * p / 100;
+ int newHeight = h * p / 100;
+ if (newWidth <= 0 || newHeight <= 0) {
+ return bitmap;
+ }
+ Bitmap ret = Bitmap.createScaledBitmap(bitmap, newWidth, newHeight, true);
+ if (ret != bitmap) {
+ bitmap.recycle();
+ }
+ return ret;
+ }
+ return bitmap;
+ }
+}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
index d9df7b7fc..4c74b16ca 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageShow.java
@@ -75,10 +75,6 @@ public class ImageShow extends View implements OnGestureListener,
private Bitmap mFiltersOnlyImage = null;
private Bitmap mFilteredImage = null;
- private final boolean USE_SLIDER_GESTURE = false; // set to true to have
- // slider gesture
- protected SliderController mSliderController = new SliderController();
-
private GestureDetector mGestureDetector = null;
private HistoryAdapter mHistoryAdapter = null;
@@ -153,15 +149,15 @@ public class ImageShow extends View implements OnGestureListener,
private final Handler mHandler = new Handler();
public void select() {
+ if (mSeekBar != null) {
+ mSeekBar.setOnSeekBarChangeListener(this);
+ }
if (getCurrentFilter() != null) {
int parameter = getCurrentFilter().getParameter();
int maxp = getCurrentFilter().getMaxParameter();
int minp = getCurrentFilter().getMinParameter();
updateSeekBar(parameter, minp, maxp);
}
- if (mSeekBar != null) {
- mSeekBar.setOnSeekBarChangeListener(this);
- }
}
private int parameterToUI(int parameter, int minp, int maxp, int uimax) {
@@ -179,9 +175,6 @@ public class ImageShow extends View implements OnGestureListener,
int seekMax = mSeekBar.getMax();
int progress = parameterToUI(parameter, minp, maxp, seekMax);
mSeekBar.setProgress(progress);
- if (getPanelController() != null) {
- getPanelController().onNewValue(parameter);
- }
}
public void unselect() {
@@ -198,10 +191,8 @@ public class ImageShow extends View implements OnGestureListener,
public void resetParameter() {
ImageFilter currentFilter = getCurrentFilter();
if (currentFilter != null) {
- onNewValue(currentFilter.getDefaultParameter());
- }
- if (USE_SLIDER_GESTURE) {
- mSliderController.reset();
+ updateSeekBar(currentFilter.getDefaultParameter(),
+ getCurrentFilter().getMinParameter(), getCurrentFilter().getMaxParameter());
}
}
@@ -215,8 +206,8 @@ public class ImageShow extends View implements OnGestureListener,
@Override
public void onNewValue(int parameter) {
- int maxp = 100;
- int minp = -100;
+ int maxp = ImageFilter.DEFAULT_MAX_PARAMETER;
+ int minp = ImageFilter.DEFAULT_MIN_PARAMETER;
if (getCurrentFilter() != null) {
getCurrentFilter().setParameter(parameter);
maxp = getCurrentFilter().getMaxParameter();
@@ -229,7 +220,6 @@ public class ImageShow extends View implements OnGestureListener,
if (getPanelController() != null) {
getPanelController().onNewValue(parameter);
}
- updateSeekBar(parameter, minp, maxp);
invalidate();
mActivity.enableSave(hasModifications());
}
@@ -247,9 +237,6 @@ public class ImageShow extends View implements OnGestureListener,
public ImageShow(Context context, AttributeSet attrs) {
super(context, attrs);
- if (USE_SLIDER_GESTURE) {
- mSliderController.setListener(this);
- }
mHistoryAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
R.id.rowTextView);
mImageStateAdapter = new ImageStateAdapter(context,
@@ -260,9 +247,6 @@ public class ImageShow extends View implements OnGestureListener,
public ImageShow(Context context) {
super(context);
- if (USE_SLIDER_GESTURE) {
- mSliderController.setListener(this);
- }
mHistoryAdapter = new HistoryAdapter(context, R.layout.filtershow_history_operation_row,
R.id.rowTextView);
setupGestureDetector(context);
@@ -278,10 +262,6 @@ public class ImageShow extends View implements OnGestureListener,
int parentWidth = MeasureSpec.getSize(widthMeasureSpec);
int parentHeight = MeasureSpec.getSize(heightMeasureSpec);
setMeasuredDimension(parentWidth, parentHeight);
- if (USE_SLIDER_GESTURE) {
- mSliderController.setWidth(parentWidth);
- mSliderController.setHeight(parentHeight);
- }
}
public void setSeekBar(SeekBar seekBar) {
@@ -383,12 +363,6 @@ public class ImageShow extends View implements OnGestureListener,
1.5f * mTextPadding, mPaint);
}
- if (showControls()) {
- if (USE_SLIDER_GESTURE) {
- mSliderController.onDraw(canvas);
- }
- }
-
drawToast(canvas);
}
@@ -685,9 +659,6 @@ public class ImageShow extends View implements OnGestureListener,
@Override
public boolean onTouchEvent(MotionEvent event) {
super.onTouchEvent(event);
- if (USE_SLIDER_GESTURE) {
- mSliderController.onTouchEvent(event);
- }
if (mGestureDetector != null) {
mGestureDetector.onTouchEvent(event);
}
diff --git a/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java b/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java
index c7586fe9b..b66da0128 100644
--- a/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java
+++ b/src/com/android/gallery3d/filtershow/imageshow/ImageZoom.java
@@ -128,10 +128,6 @@ public class ImageZoom extends ImageSlave {
drawImage(canvas, filteredImage);
canvas.restore();
- if (showControls()) {
- mSliderController.onDraw(canvas);
- }
-
drawToast(canvas);
}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java
deleted file mode 100644
index bfa6dacc7..000000000
--- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBW.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.presets;
-
-import com.android.gallery3d.filtershow.filters.ImageFilterBW;
-
-public class ImagePresetBW extends ImagePreset {
-
- @Override
- public String name() {
- return "B&W";
- }
-
- @Override
- public void setup() {
- mFilters.add(new ImageFilterBW());
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java
deleted file mode 100644
index 5d56aa1cd..000000000
--- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWBlue.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.presets;
-
-import com.android.gallery3d.filtershow.filters.ImageFilterBWBlue;
-
-public class ImagePresetBWBlue extends ImagePreset {
-
- @Override
- public String name() {
- return "B&W - Blue";
- }
-
- @Override
- public void setup() {
- mFilters.add(new ImageFilterBWBlue());
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java
deleted file mode 100644
index d1b4e5d78..000000000
--- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWGreen.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.presets;
-
-import com.android.gallery3d.filtershow.filters.ImageFilterBWGreen;
-
-public class ImagePresetBWGreen extends ImagePreset {
-
- @Override
- public String name() {
- return "B&W - Green";
- }
-
- @Override
- public void setup() {
- mFilters.add(new ImageFilterBWGreen());
- }
-
-}
diff --git a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java b/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java
deleted file mode 100644
index 9653bed57..000000000
--- a/src/com/android/gallery3d/filtershow/presets/ImagePresetBWRed.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.gallery3d.filtershow.presets;
-
-import com.android.gallery3d.filtershow.filters.ImageFilterBWRed;
-
-public class ImagePresetBWRed extends ImagePreset {
-
- @Override
- public String name() {
- return "B&W - Red";
- }
-
- @Override
- public void setup() {
- mFilters.add(new ImageFilterBWRed());
- }
-
-}