SDL3_gfx 1.0.1 Graphics primitives and surface functions for SDL3

SDL3_imageFilter.h
Go to the documentation of this file.
1/*
2
3 SDL3_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 _SDL3_imageFilter_h
31#define _SDL3_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(LIBSDL3_GFX_DLL_IMPORT)
42# define SDL3_IMAGEFILTER_SCOPE __declspec(dllexport)
43# else
44# ifdef LIBSDL3_GFX_DLL_IMPORT
45# define SDL3_IMAGEFILTER_SCOPE __declspec(dllimport)
46# endif
47# endif
48#endif
49#ifndef SDL3_IMAGEFILTER_SCOPE
50# define SDL3_IMAGEFILTER_SCOPE extern
51#endif
52
53 /* Comments: */
54 /* 1.) Convolution routines do not have C routines at this time. */
55
56 //
57 // All routines return:
58 // 0 OK
59 // -1 Error (internal error, parameter error)
60 //
61
62 // SDL_imageFilterAdd: D = saturation255(S1 + S2)
63 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
64
65 // SDL_imageFilterMean: D = S1/2 + S2/2
66 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
67
68 // SDL_imageFilterSub: D = saturation0(S1 - S2)
69 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
70
71 // SDL_imageFilterAbsDiff: D = | S1 - S2 |
72 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
73
74 // SDL_imageFilterMult: D = saturation(S1 * S2)
75 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
76
77 // SDL_imageFilterMultNor: D = S1 * S2
78 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
79
80 // SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
81 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
82 unsigned int length);
83
84 // SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
85 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest,
86 unsigned int length);
87
88 // SDL_imageFilterBitAnd: D = S1 & S2
89 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
90
91 // SDL_imageFilterBitOr: D = S1 | S2
92 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
93
94 // SDL_imageFilterDiv: D = S1 / S2
95 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length);
96
97 // SDL_imageFilterBitNegation: D = !S
98 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length);
99
100 // SDL_imageFilterAddByte: D = saturation255(S + C)
101 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
102
103 // SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
104 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int bpp, unsigned int C);
105
106 // SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
107 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length,
108 unsigned char C);
109
110 // SDL_imageFilterSubByte: D = saturation0(S - C)
111 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
112
113 // SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
114 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int bpp, unsigned int C);
115
116 // SDL_imageFilterShiftRight: D = saturation0(S >> N)
117 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
118
119 // SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
120 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
121
122 // SDL_imageFilterMultByByte: D = saturation255(S * C)
123 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C);
124
125 // SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
126 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
127 unsigned char N, unsigned char C);
128
129 // SDL_imageFilterShiftLeftByte: D = (S << N)
130 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length,
131 unsigned char N);
132
133 // SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
134 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length,
135 unsigned char N);
136
137 // SDL_imageFilterShiftLeft: D = saturation255(S << N)
138 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N);
139
140 // SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
141 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length,
142 unsigned char T);
143
144 // SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
145 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length,
146 unsigned char Tmin, unsigned char Tmax);
147
148 // SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
149 SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin,
150 int Cmax, int Nmin, int Nmax);
151
152 /* Ends C function definitions when using C++ */
153#ifdef __cplusplus
154}
155#endif
156
157#endif /* _SDL3_imageFilter_h */
SDL_imageFilterAddUint
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int bpp, unsigned int C)
Filter using AddUint: D = saturation255((S[i] + Cs[i % BPP])
Definition SDL3_imageFilter.c:597
SDL_imageFilterSubUint
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSubUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned int bpp, unsigned int C)
Filter using SubUint: D = saturation0(S[i] - Cs[i % BPP])
Definition SDL3_imageFilter.c:747
SDL_imageFilterBitAnd
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitAnd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using BitAnd: D = S1 & S2.
Definition SDL3_imageFilter.c:390
SDL_imageFilterMultByByte
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C)
Filter using MultByByte: D = saturation255(S * C)
Definition SDL3_imageFilter.c:907
SDL_imageFilterClipToRange
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterClipToRange(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char Tmin, unsigned char Tmax)
Filter using ClipToRange: D = (S >= Tmin) & (S <= Tmax) S:Tmin | Tmax.
Definition SDL3_imageFilter.c:1214
SDL_imageFilterSub
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSub(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using Sub: D = saturation0(S1 - S2)
Definition SDL3_imageFilter.c:143
SDL_imageFilterSubByte
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterSubByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C)
Filter using SubByte: D = saturation0(S - C)
Definition SDL3_imageFilter.c:697
SDL_imageFilterDiv
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterDiv(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using Div: D = S1 / S2.
Definition SDL3_imageFilter.c:468
SDL_imageFilterShiftRightAndMultByByte
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightAndMultByByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N, unsigned char C)
Filter using ShiftRightAndMultByByte: D = saturation255((S >> N) * C)
Definition SDL3_imageFilter.c:958
SDL_imageFilterNormalizeLinear
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterNormalizeLinear(unsigned char *Src, unsigned char *Dest, unsigned int length, int Cmin, int Cmax, int Nmin, int Nmax)
Filter using NormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
Definition SDL3_imageFilter.c:1268
SDL_imageFilterShiftRightUint
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRightUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N)
Filter using ShiftRightUint: D = saturation0((uint)S[i] >> N)
Definition SDL3_imageFilter.c:853
SDL_imageFilterBitOr
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitOr(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using BitOr: D = S1 | S2.
Definition SDL3_imageFilter.c:429
SDL_imageFilterBinarizeUsingThreshold
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBinarizeUsingThreshold(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char T)
Filter using BinarizeUsingThreshold: D = (S >= T) ? 255:0.
Definition SDL3_imageFilter.c:1169
SDL3_IMAGEFILTER_SCOPE
#define SDL3_IMAGEFILTER_SCOPE
Definition SDL3_imageFilter.h:50
SDL_imageFilterAddByteToHalf
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddByteToHalf(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C)
Filter using AddByteToHalf: D = saturation255(S/2 + C)
Definition SDL3_imageFilter.c:652
SDL_imageFilterMean
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMean(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using Mean: D = S1/2 + S2/2.
Definition SDL3_imageFilter.c:101
SDL_imageFilterMultDivby4
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby4(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using MultDivby4: D = saturation255(S1/2 * S2/2)
Definition SDL3_imageFilter.c:347
SDL_imageFilterShiftRight
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftRight(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N)
Filter using ShiftRight: D = saturation0(S >> N)
Definition SDL3_imageFilter.c:803
SDL_imageFilterAbsDiff
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAbsDiff(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using AbsDiff: D = | S1 - S2 |.
Definition SDL3_imageFilter.c:181
SDL_imageFilterMultDivby2
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultDivby2(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using MultDivby2: D = saturation255(S1/2 * S2)
Definition SDL3_imageFilter.c:304
SDL_imageFilterShiftLeftByte
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N)
Filter using ShiftLeftByte: D = (S << N)
Definition SDL3_imageFilter.c:1014
SDL_imageFilterAdd
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAdd(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using Add: D = saturation255(S1 + S2)
Definition SDL3_imageFilter.c:58
SDL_imageFilterShiftLeftUint
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeftUint(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N)
Filter using ShiftLeftUint: D = ((uint)S << N)
Definition SDL3_imageFilter.c:1064
SDL_imageFilterAddByte
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterAddByte(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char C)
Filter using AddByte: D = saturation255(S + C)
Definition SDL3_imageFilter.c:548
SDL_imageFilterMult
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMult(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using Mult: D = saturation255(S1 * S2)
Definition SDL3_imageFilter.c:222
SDL_imageFilterShiftLeft
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterShiftLeft(unsigned char *Src1, unsigned char *Dest, unsigned int length, unsigned char N)
Filter ShiftLeft: D = saturation255(S << N)
Definition SDL3_imageFilter.c:1118
SDL_imageFilterBitNegation
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterBitNegation(unsigned char *Src1, unsigned char *Dest, unsigned int length)
Filter using BitNegation: D = !S.
Definition SDL3_imageFilter.c:511
SDL_imageFilterMultNor
SDL3_IMAGEFILTER_SCOPE int SDL_imageFilterMultNor(unsigned char *Src1, unsigned char *Src2, unsigned char *Dest, unsigned int length)
Filter using MultNor: D = S1 * S2.
Definition SDL3_imageFilter.c:265