1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef FILTERS_H
18 #define FILTERS_H
19 
20 #include <jni.h>
21 #include <string.h>
22 #include <android/log.h>
23 #include <android/bitmap.h>
24 
25 typedef unsigned int Color;
26 
27 #define SetColor(a, r, g, b) (((a) << 24) | ((b) << 16) | ((g) << 8) | ((r) << 0));
28 #define GetA(color) (((color) >> 24) & 0xFF)
29 #define GetB(color) (((color) >> 16) & 0xFF)
30 #define GetG(color) (((color) >> 8) & 0xFF)
31 #define GetR(color) (((color) >> 0) & 0xFF)
32 
33 #define MIN(a, b) ((a) < (b) ? (a) : (b))
34 #define MAX(a, b) ((a) > (b) ? (a) : (b))
35 
36 #define LOG(msg...) __android_log_print(ANDROID_LOG_VERBOSE, "NativeFilters", msg)
37 
38 #define JNIFUNCF(cls, name, vars...) Java_com_android_gallery3d_filtershow_filters_ ## cls ## _ ## name(JNIEnv* env, jobject obj_unused __unused, vars)
39 
40 #define RED i
41 #define GREEN (i+1)
42 #define BLUE (i+2)
43 #define ALPHA (i+3)
44 #define CLAMP(c) (MAX(0, MIN(255, c)))
45 
46 extern unsigned char  clamp(int c);
47 extern int clampMax(int c,int max);
48 
49 extern void rgb2hsv( unsigned char *rgb,int rgbOff,unsigned short *hsv,int hsvOff);
50 extern void hsv2rgb(unsigned short *hsv,int hsvOff,unsigned char  *rgb,int rgbOff);
51 extern void filterRedEye(unsigned char *src, unsigned char *dest, int iw, int ih, short *rect);
52 extern double fastevalPoly(double *poly,int n, double x);
53 #endif // FILTERS_H
54