From b8bf8a5b773e5f049b80a082177c6398a95ddd4a Mon Sep 17 00:00:00 2001 From: John Hoford Date: Mon, 1 Oct 2012 17:21:55 -0700 Subject: Fix exposure and fixed warnings bug:7234321 --- jni/Android.mk | 2 +- jni/filters/brightness.c | 37 ------------------------------------- jni/filters/contrast.c | 1 + jni/filters/exposure.c | 37 +++++++++++++++++++++++++++++++++++++ jni/filters/filters.h | 2 +- jni/filters/vignette.c | 2 +- 6 files changed, 41 insertions(+), 40 deletions(-) delete mode 100644 jni/filters/brightness.c create mode 100644 jni/filters/exposure.c (limited to 'jni') diff --git a/jni/Android.mk b/jni/Android.mk index 8453f76d1..38fa453b9 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/brightness.c b/jni/filters/brightness.c deleted file mode 100644 index 88044a28c..000000000 --- a/jni/filters/brightness.c +++ /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. - */ - -#include "filters.h" - -void JNIFUNCF(ImageFilterBrightness, 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; - - 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); - } - AndroidBitmap_unlockPixels(env, bitmap); -} - diff --git a/jni/filters/contrast.c b/jni/filters/contrast.c index 45209c1fb..6c1b976cf 100644 --- a/jni/filters/contrast.c +++ b/jni/filters/contrast.c @@ -14,6 +14,7 @@ * limitations under the License. */ +#include #include "filters.h" unsigned char clamp(int c) diff --git a/jni/filters/exposure.c b/jni/filters/exposure.c new file mode 100644 index 000000000..6b32798c8 --- /dev/null +++ b/jni/filters/exposure.c @@ -0,0 +1,37 @@ +/* + * 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(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 m = (255-bright); + + for (i = 0; i < len; i+=4) + { + 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 5fe595b9e..44a442290 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 7cff517b6..2799ff001 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)) { -- cgit v1.2.3