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
* limitations under the License.
*/
+#include <math.h>
#include "filters.h"
unsigned char clamp(int c)
#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);
}
#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
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))
{
mImageShow.setVisibility(View.VISIBLE);
mImageShow.setShowControls(true);
ImagePreset preset = mImageShow.getImagePreset();
- ImageFilter filter = preset.getFilter("Brightness");
+ ImageFilter filter = preset.getFilter("Exposure");
if (filter == null) {
- ImageFilterBrightness bright = new ImageFilterBrightness();
+ ImageFilterExposure bright = new ImageFilterExposure();
ImagePreset copy = new ImagePreset(preset);
copy.add(bright);
copy.setHistoryName(bright.getName());
copy.setIsFx(false);
- filter = copy.getFilter("Brightness");
+ filter = copy.getFilter("Exposure");
mImageShow.setImagePreset(copy);
}
mImageShow.setCurrentFilter(filter);
import android.graphics.Bitmap;
-public class ImageFilterBrightness extends ImageFilter {
+public class ImageFilterExposure extends ImageFilter {
- public ImageFilterBrightness() {
- mName = "Brightness";
+ public ImageFilterExposure() {
+ mName = "Exposure";
}
native protected void nativeApplyFilter(Bitmap bitmap, int w, int h, float bright);
+ @Override
public void apply(Bitmap bitmap) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();