summaryrefslogtreecommitdiffstats
path: root/jni/filters/filters.h
diff options
context:
space:
mode:
Diffstat (limited to 'jni/filters/filters.h')
-rw-r--r--jni/filters/filters.h20
1 files changed, 18 insertions, 2 deletions
diff --git a/jni/filters/filters.h b/jni/filters/filters.h
index 3f8c3a07e..55c260f06 100644
--- a/jni/filters/filters.h
+++ b/jni/filters/filters.h
@@ -44,8 +44,24 @@ typedef unsigned int Color;
#define ALPHA i+3
#define CLAMP(c) (MAX(0, MIN(255, c)))
-__inline__ unsigned char clamp(int c);
-__inline__ int clampMax(int c,int max);
+__inline__ unsigned char clamp(int c)
+{
+ int N = 255;
+ c &= ~(c >> 31);
+ c -= N;
+ c &= (c >> 31);
+ c += N;
+ return (unsigned char) c;
+}
+
+__inline__ int clampMax(int c,int max)
+{
+ c &= ~(c >> 31);
+ c -= max;
+ c &= (c >> 31);
+ c += max;
+ return c;
+}
extern void rgb2hsv( unsigned char *rgb,int rgbOff,unsigned short *hsv,int hsvOff);
extern void hsv2rgb(unsigned short *hsv,int hsvOff,unsigned char *rgb,int rgbOff);