summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2012-12-10 19:40:27 -0800
committerRuben Brunk <rubenbrunk@google.com>2012-12-12 16:03:45 -0800
commitce178c1fa02362636e4992834592d6e019e4ee80 (patch)
treea7b50c8bd6e67540447761599b07271cf8ec484c
parentbf1baf80e1463dfacf4a3a486625523a76479a00 (diff)
downloadandroid_packages_apps_Gallery2-ce178c1fa02362636e4992834592d6e019e4ee80.tar.gz
android_packages_apps_Gallery2-ce178c1fa02362636e4992834592d6e019e4ee80.tar.bz2
android_packages_apps_Gallery2-ce178c1fa02362636e4992834592d6e019e4ee80.zip
Added photonegative filter.
Change-Id: I73594573b26873cb3fda49aca6d40761dec3707f
-rw-r--r--jni/Android.mk1
-rw-r--r--jni/filters/negative.c33
-rw-r--r--res/values/filtershow_ids.xml1
-rw-r--r--res/values/filtershow_strings.xml2
-rw-r--r--src/com/android/gallery3d/filtershow/FilterShowActivity.java4
-rw-r--r--src/com/android/gallery3d/filtershow/PanelController.java3
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilter.java4
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java5
-rw-r--r--src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java47
9 files changed, 98 insertions, 2 deletions
diff --git a/jni/Android.mk b/jni/Android.mk
index db31bfdf6..8a2fc9e18 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -35,6 +35,7 @@ LOCAL_SRC_FILES := filters/bw.c \
filters/hsv.c \
filters/vibrance.c \
filters/geometry.c \
+ filters/negative.c \
filters/vignette.c \
filters/redEyeMath.c \
filters/fx.c \
diff --git a/jni/filters/negative.c b/jni/filters/negative.c
new file mode 100644
index 000000000..735e583c9
--- /dev/null
+++ b/jni/filters/negative.c
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+#include "filters.h"
+
+void JNIFUNCF(ImageFilterNegative, nativeApplyFilter, jobject bitmap, jint width, jint height)
+{
+ char* destination = 0;
+ AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
+
+ int tot_len = height * width * 4;
+ int i;
+ char * dst = destination;
+ for (i = 0; i < tot_len; i+=4) {
+ dst[RED] = 255 - dst[RED];
+ dst[GREEN] = 255 - dst[GREEN];
+ dst[BLUE] = 255 - dst[BLUE];
+ }
+ AndroidBitmap_unlockPixels(env, bitmap);
+}
diff --git a/res/values/filtershow_ids.xml b/res/values/filtershow_ids.xml
index 502d2f8cb..7f7c98bd0 100644
--- a/res/values/filtershow_ids.xml
+++ b/res/values/filtershow_ids.xml
@@ -30,4 +30,5 @@
<item type="id" name="shadowRecoveryButton" />
<item type="id" name="sharpenButton" />
<item type="id" name="curvesButtonRGB" />
+ <item type="id" name="negativeButton" />
</resources>
diff --git a/res/values/filtershow_strings.xml b/res/values/filtershow_strings.xml
index 7cfcfa093..e011396cd 100644
--- a/res/values/filtershow_strings.xml
+++ b/res/values/filtershow_strings.xml
@@ -131,6 +131,8 @@
<string name="rotate" msgid="460017689320955494">Rotate</string>
<!-- Label for the image flip effect [CHAR LIMIT=15] -->
<string name="mirror">Mirror</string>
+ <!-- Name for the photo effect that inverts photo to negative images. [CHAR LIMIT=10] -->
+ <string name="negative">Negative</string>
<!-- Label for having no filters applied to the image [CHAR LIMIT=10] -->
<string name="none" msgid="3601545724573307541">None</string>
diff --git a/src/com/android/gallery3d/filtershow/FilterShowActivity.java b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
index c7de01837..6275ae62d 100644
--- a/src/com/android/gallery3d/filtershow/FilterShowActivity.java
+++ b/src/com/android/gallery3d/filtershow/FilterShowActivity.java
@@ -64,6 +64,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
import com.android.gallery3d.filtershow.filters.ImageFilterExposure;
import com.android.gallery3d.filtershow.filters.ImageFilterFx;
import com.android.gallery3d.filtershow.filters.ImageFilterHue;
+import com.android.gallery3d.filtershow.filters.ImageFilterNegative;
import com.android.gallery3d.filtershow.filters.ImageFilterParametricBorder;
import com.android.gallery3d.filtershow.filters.ImageFilterRS;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
@@ -307,7 +308,8 @@ public class FilterShowActivity extends Activity implements OnItemClickListener,
new ImageFilterCurves(),
new ImageFilterHue(),
new ImageFilterSaturated(),
- new ImageFilterBwFilter()
+ new ImageFilterBwFilter(),
+ new ImageFilterNegative()
};
for (int i = 0; i < filters.length; i++) {
diff --git a/src/com/android/gallery3d/filtershow/PanelController.java b/src/com/android/gallery3d/filtershow/PanelController.java
index 4f59258ed..41833a668 100644
--- a/src/com/android/gallery3d/filtershow/PanelController.java
+++ b/src/com/android/gallery3d/filtershow/PanelController.java
@@ -32,6 +32,7 @@ import com.android.gallery3d.filtershow.filters.ImageFilterContrast;
import com.android.gallery3d.filtershow.filters.ImageFilterCurves;
import com.android.gallery3d.filtershow.filters.ImageFilterExposure;
import com.android.gallery3d.filtershow.filters.ImageFilterHue;
+import com.android.gallery3d.filtershow.filters.ImageFilterNegative;
import com.android.gallery3d.filtershow.filters.ImageFilterRedEye;
import com.android.gallery3d.filtershow.filters.ImageFilterSaturated;
import com.android.gallery3d.filtershow.filters.ImageFilterShadows;
@@ -571,9 +572,9 @@ public class PanelController implements OnClickListener {
if (view.getId() == R.id.curvesButtonRGB) {
// TODO: delegate to the filter / editing view the management of the
// panel accessory view
- mUtilityPanel.setShowParameter(false);
mUtilityPanel.showCurvesButtons();
}
+ mUtilityPanel.setShowParameter(filter.showParameterValue());
ensureFilter(ename);
mCurrentImage.select();
}
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
index 8bd855660..2319fcc12 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilter.java
@@ -68,6 +68,10 @@ public class ImageFilter implements Cloneable {
return true;
}
+ public boolean showParameterValue() {
+ return true;
+ }
+
@Override
public ImageFilter clone() throws CloneNotSupportedException {
ImageFilter filter = (ImageFilter) super.clone();
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
index 46a00f47a..ba49a8fcb 100644
--- a/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterCurves.java
@@ -52,6 +52,11 @@ public class ImageFilterCurves extends ImageFilter {
}
@Override
+ public boolean showParameterValue() {
+ return false;
+ }
+
+ @Override
public ImageFilter clone() throws CloneNotSupportedException {
ImageFilterCurves filter = (ImageFilterCurves) super.clone();
for (int i = 0; i < 4; i++) {
diff --git a/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
new file mode 100644
index 000000000..04fd1e42e
--- /dev/null
+++ b/src/com/android/gallery3d/filtershow/filters/ImageFilterNegative.java
@@ -0,0 +1,47 @@
+package com.android.gallery3d.filtershow.filters;
+
+import android.graphics.Bitmap;
+
+import com.android.gallery3d.R;
+
+public class ImageFilterNegative extends ImageFilter {
+
+ public ImageFilterNegative() {
+ mName = "Negative";
+ }
+
+ @Override
+ public int getButtonId() {
+ return R.id.negativeButton;
+ }
+
+ @Override
+ public int getTextId() {
+ return R.string.negative;
+ }
+
+ @Override
+ public boolean isNil() {
+ return false;
+ }
+
+ @Override
+ public boolean showEditingControls() {
+ return false;
+ }
+
+ @Override
+ public boolean showParameterValue() {
+ return false;
+ }
+
+ 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;
+ }
+}