summaryrefslogtreecommitdiffstats
path: root/jni
diff options
context:
space:
mode:
authorJohn Hoford <hoford@google.com>2012-10-02 00:21:55 (GMT)
committerJohn Hoford <hoford@google.com>2012-10-02 00:47:50 (GMT)
commitb8bf8a5b773e5f049b80a082177c6398a95ddd4a (patch)
tree3c20261147bde464da6bdffd102118fad8981a3c /jni
parent912ea3074e9551640b96b87b04a0f30504542c52 (diff)
downloadandroid_packages_apps_Snap-b8bf8a5b773e5f049b80a082177c6398a95ddd4a.zip
android_packages_apps_Snap-b8bf8a5b773e5f049b80a082177c6398a95ddd4a.tar.gz
android_packages_apps_Snap-b8bf8a5b773e5f049b80a082177c6398a95ddd4a.tar.bz2
Fix exposure and fixed warnings
bug:7234321
Diffstat (limited to 'jni')
-rw-r--r--jni/Android.mk2
-rw-r--r--jni/filters/contrast.c1
-rw-r--r--jni/filters/exposure.c (renamed from jni/filters/brightness.c)12
-rw-r--r--jni/filters/filters.h2
-rw-r--r--jni/filters/vignette.c2
5 files changed, 10 insertions, 9 deletions
diff --git a/jni/Android.mk b/jni/Android.mk
index 8453f76..38fa453 100644
--- a/jni/Android.mk
+++ b/jni/Android.mk
@@ -27,7 +27,7 @@ LOCAL_MODULE := libjni_filtershow_filters
LOCAL_SRC_FILES := filters/bw.c \
filters/gradient.c \
filters/saturated.c \
- filters/brightness.c \
+ filters/exposure.c \
filters/contrast.c \
filters/hue.c \
filters/vignette.c
diff --git a/jni/filters/contrast.c b/jni/filters/contrast.c
index 45209c1..6c1b976 100644
--- a/jni/filters/contrast.c
+++ b/jni/filters/contrast.c
@@ -14,6 +14,7 @@
* limitations under the License.
*/
+#include <math.h>
#include "filters.h"
unsigned char clamp(int c)
diff --git a/jni/filters/brightness.c b/jni/filters/exposure.c
index 88044a2..6b32798 100644
--- a/jni/filters/brightness.c
+++ b/jni/filters/exposure.c
@@ -16,21 +16,21 @@
#include "filters.h"
-void JNIFUNCF(ImageFilterBrightness, nativeApplyFilter, jobject bitmap, jint width, jint height, jfloat bright)
+void JNIFUNCF(ImageFilterExposure, nativeApplyFilter, jobject bitmap, jint width, jint height, jfloat bright)
{
char* destination = 0;
AndroidBitmap_lockPixels(env, bitmap, (void**) &destination);
unsigned char * rgb = (unsigned char * )destination;
int i;
int len = width * height * 4;
- int c = (int)(bright);
- int m = (c>0)?(255+c):255;
+
+ int m = (255-bright);
for (i = 0; i < len; i+=4)
{
- rgb[RED] = clamp((255*(rgb[RED]))/m+c);
- rgb[GREEN] = clamp((255*(rgb[GREEN]))/m+c);
- rgb[BLUE] = clamp((255*(rgb[BLUE]))/m+c);
+ rgb[RED] = clamp((255*(rgb[RED]))/m);
+ rgb[GREEN] = clamp((255*(rgb[GREEN]))/m);
+ rgb[BLUE] = clamp((255*(rgb[BLUE]))/m);
}
AndroidBitmap_unlockPixels(env, bitmap);
}
diff --git a/jni/filters/filters.h b/jni/filters/filters.h
index 5fe595b..44a4422 100644
--- a/jni/filters/filters.h
+++ b/jni/filters/filters.h
@@ -43,6 +43,6 @@ typedef unsigned int Color;
#define ALPHA i+3
#define CLAMP(c) (MAX(0, MIN(255, c)))
-unsigned char __inline__ clamp(int c);
+__inline__ unsigned char clamp(int c);
#endif // FILTERS_H
diff --git a/jni/filters/vignette.c b/jni/filters/vignette.c
index 7cff517..2799ff0 100644
--- a/jni/filters/vignette.c
+++ b/jni/filters/vignette.c
@@ -20,7 +20,7 @@ static int* gVignetteMap = 0;
static int gVignetteWidth = 0;
static int gVignetteHeight = 0;
-void __inline__ createVignetteMap(int w, int h)
+__inline__ void createVignetteMap(int w, int h)
{
if (gVignetteMap && (gVignetteWidth != w || gVignetteHeight != h))
{