SDL_gfx  2.0.25
I:/Sources/sdlgfx/SDL_imageFilter.h
Go to the documentation of this file.
00001 /*
00002 
00003 SDL_imageFilter.h: byte-image "filter" routines 
00004 
00005 Copyright (C) 2001-2012  Andreas Schiffler
00006 
00007 This software is provided 'as-is', without any express or implied
00008 warranty. In no event will the authors be held liable for any damages
00009 arising from the use of this software.
00010 
00011 Permission is granted to anyone to use this software for any purpose,
00012 including commercial applications, and to alter it and redistribute it
00013 freely, subject to the following restrictions:
00014 
00015 1. The origin of this software must not be misrepresented; you must not
00016 claim that you wrote the original software. If you use this software
00017 in a product, an acknowledgment in the product documentation would be
00018 appreciated but is not required.
00019 
00020 2. Altered source versions must be plainly marked as such, and must not be
00021 misrepresented as being the original software.
00022 
00023 3. This notice may not be removed or altered from any source
00024 distribution.
00025 
00026 Andreas Schiffler -- aschiffler at ferzkopp dot net
00027 
00028 */
00029 
00030 #ifndef _SDL_imageFilter_h
00031 #define _SDL_imageFilter_h
00032 
00033 /* Set up for C function definitions, even when using C++ */
00034 #ifdef __cplusplus
00035 extern "C" {
00036 #endif
00037 
00038         /* ---- Function Prototypes */
00039 
00040 #ifdef _MSC_VER
00041 #  if defined(DLL_EXPORT) && !defined(LIBSDL_GFX_DLL_IMPORT)
00042 #    define SDL_IMAGEFILTER_SCOPE __declspec(dllexport)
00043 #  else
00044 #    ifdef LIBSDL_GFX_DLL_IMPORT
00045 #      define SDL_IMAGEFILTER_SCOPE __declspec(dllimport)
00046 #    endif
00047 #  endif
00048 #endif
00049 #ifndef SDL_IMAGEFILTER_SCOPE
00050 #  define SDL_IMAGEFILTER_SCOPE extern
00051 #endif
00052 
00053         /* Comments:                                                                           */
00054         /*  1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. */
00055         /*  2.) Data that is not within an 8 byte boundary is processed using the C routine.   */
00056         /*  3.) Convolution routines do not have C routines at this time.                      */
00057 
00058         // Detect MMX capability in CPU
00059         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMMXdetect(void);
00060 
00061         // Force use of MMX off (or turn possible use back on)
00062         SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXoff(void);
00063         SDL_IMAGEFILTER_SCOPE void SDL_imageFilterMMXon(void);
00064 
00065         //
00066         // All routines return:
00067         //   0   OK
00068         //  -1   Error (internal error, parameter error)
00069         //
00070 
00071         //  SDL_imageFilterAdd: D = saturation255(S1 + S2)
00072         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00073 
00074         //  SDL_imageFilterMean: D = S1/2 + S2/2
00075         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00076 
00077         //  SDL_imageFilterSub: D = saturation0(S1 - S2)
00078         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00079 
00080         //  SDL_imageFilterAbsDiff: D = | S1 - S2 |
00081         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00082 
00083         //  SDL_imageFilterMult: D = saturation(S1 * S2)
00084         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00085 
00086         //  SDL_imageFilterMultNor: D = S1 * S2   (non-MMX)
00087         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00088 
00089         //  SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
00090         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
00091                 unsigned int length);
00092 
00093         //  SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
00094         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
00095                 unsigned int length);
00096 
00097         //  SDL_imageFilterBitAnd: D = S1 & S2
00098         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00099 
00100         //  SDL_imageFilterBitOr: D = S1 | S2
00101         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00102 
00103         //  SDL_imageFilterDiv: D = S1 / S2   (non-MMX)
00104         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
00105 
00106         //  SDL_imageFilterBitNegation: D = !S
00107         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length);
00108 
00109         //  SDL_imageFilterAddByte: D = saturation255(S + C)
00110         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
00111 
00112         //  SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
00113         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
00114 
00115         //  SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
00116         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00117                 unsigned char C);
00118 
00119         //  SDL_imageFilterSubByte: D = saturation0(S - C)
00120         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
00121 
00122         //  SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
00123         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int C);
00124 
00125         //  SDL_imageFilterShiftRight: D = saturation0(S >> N)
00126         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
00127 
00128         //  SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
00129         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
00130 
00131         //  SDL_imageFilterMultByByte: D = saturation255(S * C)
00132         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
00133 
00134         //  SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
00135         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00136                 unsigned char N, unsigned char C);
00137 
00138         //  SDL_imageFilterShiftLeftByte: D = (S << N)
00139         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00140                 unsigned char N);
00141 
00142         //  SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
00143         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00144                 unsigned char N);
00145 
00146         //  SDL_imageFilterShiftLeft: D = saturation255(S << N)
00147         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
00148 
00149         //  SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
00150         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00151                 unsigned char T);
00152 
00153         //  SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
00154         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length,
00155                 unsigned char Tmin, unsigned char Tmax);
00156 
00157         //  SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
00158         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin,
00159                 int Cmax, int Nmin, int Nmax);
00160 
00161         /* !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! */
00162 
00163         //  SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
00164         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3Divide(unsigned char *Src, unsigned char *Dest, int rows,
00165                 int columns, signed short *Kernel, unsigned char Divisor);
00166 
00167         //  SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
00168         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5Divide(unsigned char *Src, unsigned char *Dest, int rows,
00169                 int columns, signed short *Kernel, unsigned char Divisor);
00170 
00171         //  SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
00172         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7Divide(unsigned char *Src, unsigned char *Dest, int rows,
00173                 int columns, signed short *Kernel, unsigned char Divisor);
00174 
00175         //  SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
00176         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9Divide(unsigned char *Src, unsigned char *Dest, int rows,
00177                 int columns, signed short *Kernel, unsigned char Divisor);
00178 
00179         //  SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
00180         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel3x3ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
00181                 int columns, signed short *Kernel,
00182                 unsigned char NRightShift);
00183 
00184         //  SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
00185         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel5x5ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
00186                 int columns, signed short *Kernel,
00187                 unsigned char NRightShift);
00188 
00189         //  SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
00190         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel7x7ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
00191                 int columns, signed short *Kernel,
00192                 unsigned char NRightShift);
00193 
00194         //  SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
00195         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterConvolveKernel9x9ShiftRight(unsigned char *Src, unsigned char *Dest, int rows,
00196                 int columns, signed short *Kernel,
00197                 unsigned char NRightShift);
00198 
00199         //  SDL_imageFilterSobelX: Dij = saturation255( ... )
00200         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelX(unsigned char *Src, unsigned char *Dest, int rows, int columns);
00201 
00202         //  SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
00203         SDL_IMAGEFILTER_SCOPE int SDL_imageFilterSobelXShiftRight(unsigned char *Src, unsigned char *Dest, int rows, int columns,
00204                 unsigned char NRightShift);
00205 
00206         // Align/restore stack to 32 byte boundary -- Functionality untested! --
00207         SDL_IMAGEFILTER_SCOPE void SDL_imageFilterAlignStack(void);
00208         SDL_IMAGEFILTER_SCOPE void SDL_imageFilterRestoreStack(void);
00209 
00210         /* Ends C function definitions when using C++ */
00211 #ifdef __cplusplus
00212 }
00213 #endif
00214 
00215 #endif                          /* _SDL_imageFilter_h */