Btk
SDL2_imageFilter.h
1 /*
2 
3 SDL2_imageFilter.h: byte-image "filter" routines
4 
5 Copyright (C) 2012-2014 Andreas Schiffler
6 
7 This software is provided 'as-is', without any express or implied
8 warranty. In no event will the authors be held liable for any damages
9 arising from the use of this software.
10 
11 Permission is granted to anyone to use this software for any purpose,
12 including commercial applications, and to alter it and redistribute it
13 freely, subject to the following restrictions:
14 
15 1. The origin of this software must not be misrepresented; you must not
16 claim that you wrote the original software. If you use this software
17 in a product, an acknowledgment in the product documentation would be
18 appreciated but is not required.
19 
20 2. Altered source versions must be plainly marked as such, and must not be
21 misrepresented as being the original software.
22 
23 3. This notice may not be removed or altered from any source
24 distribution.
25 
26 Andreas Schiffler -- aschiffler at ferzkopp dot net
27 
28 */
29 
30 #ifndef _SDL2_imageFilter_h
31 #define _SDL2_imageFilter_h
32 
33 /* Set up for C function definitions, even when using C++ */
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38  /* ---- Function Prototypes */
39 
40 #ifdef _MSC_VER
41 # if defined(DLL_EXPORT) && !defined(LIBSDL2_GFX_DLL_IMPORT)
42 # define SDL2_IMAGEFILTER_SCOPE __declspec(dllexport)
43 # else
44 # ifdef LIBSDL2_GFX_DLL_IMPORT
45 # define SDL2_IMAGEFILTER_SCOPE __declspec(dllimport)
46 # endif
47 # endif
48 #endif
49 #ifndef SDL2_IMAGEFILTER_SCOPE
50 # define SDL2_IMAGEFILTER_SCOPE extern
51 #endif
52 
53  /* Comments: */
54  /* 1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. */
55  /* 2.) Data that is not within an 8 byte boundary is processed using the C routine. */
56  /* 3.) Convolution routines do not have C routines at this time. */
57 
58  // Detect MMX capability in CPU
59  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMMXdetect(void);
60 
61  // Force use of MMX off (or turn possible use back on)
62  SDL2_IMAGEFILTER_SCOPE void SDL_imageFilterMMXoff(void);
63  SDL2_IMAGEFILTER_SCOPE void SDL_imageFilterMMXon(void);
64 
65  //
66  // All routines return:
67  // 0 OK
68  // -1 Error (internal error, parameter error)
69  //
70 
71  // SDL_imageFilterAdd: D = saturation255(S1 + S2)
72  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
73 
74  // SDL_imageFilterMean: D = S1/2 + S2/2
75  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
76 
77  // SDL_imageFilterSub: D = saturation0(S1 - S2)
78  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
79 
80  // SDL_imageFilterAbsDiff: D = | S1 - S2 |
81  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
82 
83  // SDL_imageFilterMult: D = saturation(S1 * S2)
84  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
85 
86  // SDL_imageFilterMultNor: D = S1 * S2 (non-MMX)
87  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
88 
89  // SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
90  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
91  unsigned int length);
92 
93  // SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
94  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
95  unsigned int length);
96 
97  // SDL_imageFilterBitAnd: D = S1 & S2
98  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
99 
100  // SDL_imageFilterBitOr: D = S1 | S2
101  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
102 
103  // SDL_imageFilterDiv: D = S1 / S2 (non-MMX)
104  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
105 
106  // SDL_imageFilterBitNegation: D = !S
107  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length);
108 
109  // SDL_imageFilterAddByte: D = saturation255(S + C)
110  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
111 
112  // SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
113  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
114 
115  // SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
116  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length,
117  unsigned char C);
118 
119  // SDL_imageFilterSubByte: D = saturation0(S - C)
120  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
121 
122  // SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
123  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
124 
125  // SDL_imageFilterShiftRight: D = saturation0(S >> N)
126  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
127 
128  // SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
129  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
130 
131  // SDL_imageFilterMultByByte: D = saturation255(S * C)
132  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
133 
134  // SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
135  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
136  unsigned char N, unsigned char C);
137 
138  // SDL_imageFilterShiftLeftByte: D = (S << N)
139  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
140  unsigned char N);
141 
142  // SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
143  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length,
144  unsigned char N);
145 
146  // SDL_imageFilterShiftLeft: D = saturation255(S << N)
147  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
148 
149  // SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
150  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length,
151  unsigned char T);
152 
153  // SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
154  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length,
155  unsigned char Tmin, unsigned char Tmax);
156 
157  // SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
158  SDL2_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin,
159  int Cmax, int Nmin, int Nmax);
160 
161  /* Ends C function definitions when using C++ */
162 #ifdef __cplusplus
163 }
164 #endif
165 
166 #endif /* _SDL_imageFilter_h */