Skip to content

Commit a7d5b2e

Browse files
committed
Add SDL3_gfx (imageFilter part)
1 parent bac7fc4 commit a7d5b2e

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed

units/SDL3_gfx.pas

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
unit SDL3_gfx;
2+
3+
{
4+
This file is part of:
5+
6+
SDL3 for Pascal
7+
(https://github.com/PascalGameDevelopment/SDL3-for-Pascal)
8+
SPDX-License-Identifier: Zlib
9+
}
10+
11+
{$I sdl.inc}
12+
13+
Interface
14+
uses
15+
{$IFDEF FPC}
16+
ctypes,
17+
{$ENDIF}
18+
SDL3;
19+
20+
const
21+
{$IFDEF WINDOWS}
22+
GFX_LibName = 'SDL3_gfx.dll';
23+
{$ENDIF}
24+
25+
{$IFDEF UNIX}
26+
{$IFDEF DARWIN}
27+
GFX_LibName = 'libSDL3_gfx.dylib';
28+
{$IFDEF FPC}
29+
{$LINKLIB libSDL3_gfx}
30+
{$ENDIF}
31+
{$ELSE}
32+
{$IFDEF FPC}
33+
GFX_LibName = 'libSDL3_gfx.so';
34+
{$ELSE}
35+
GFX_LibName = 'libSDL3_gfx.so.0';
36+
{$ENDIF}
37+
{$ENDIF}
38+
{$ENDIF}
39+
40+
{$IFDEF MACOS}
41+
GFX_LibName = 'SDL3_gfx';
42+
{$IFDEF FPC}
43+
{$linklib libSDL3_gfx}
44+
{$ENDIF}
45+
{$ENDIF}
46+
47+
{$INCLUDE SDL3_imageFilter.inc}
48+
49+
Implementation
50+
51+
End.

units/SDL3_imageFilter.inc

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
{
2+
This file is part of:
3+
4+
SDL3 for Pascal
5+
(https://github.com/PascalGameDevelopment/SDL3-for-Pascal)
6+
SPDX-License-Identifier: Zlib
7+
}
8+
9+
//
10+
// All routines return:
11+
// 0 OK
12+
// -1 Error (internal error, parameter error)
13+
//
14+
15+
// SDL_imageFilterAdd: D = saturation255(S1 + S2)
16+
function SDL_imageFilterAdd(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
17+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterAdd' {$ENDIF} {$ENDIF};
18+
19+
// SDL_imageFilterMean: D = S1/2 + S2/2
20+
function SDL_imageFilterMean(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
21+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMean' {$ENDIF} {$ENDIF};
22+
23+
// SDL_imageFilterSub: D = saturation0(S1 - S2)
24+
function SDL_imageFilterSub(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
25+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterSub' {$ENDIF} {$ENDIF};
26+
27+
// SDL_imageFilterAbsDiff: D = | S1 - S2 |
28+
function SDL_imageFilterAbsDiff(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
29+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterAbsDiff' {$ENDIF} {$ENDIF};
30+
31+
// SDL_imageFilterMult: D = saturation(S1 * S2)
32+
function SDL_imageFilterMult(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
33+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMult' {$ENDIF} {$ENDIF};
34+
35+
// SDL_imageFilterMultNor: D = S1 * S2
36+
function SDL_imageFilterMultNor(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
37+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMultNor' {$ENDIF} {$ENDIF};
38+
39+
// SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
40+
function SDL_imageFilterMultDivby2(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
41+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMultDivby2' {$ENDIF} {$ENDIF};
42+
43+
// SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
44+
function SDL_imageFilterMultDivby4(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
45+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMultDivby4' {$ENDIF} {$ENDIF};
46+
47+
// SDL_imageFilterBitAnd: D = S1 & S2
48+
function SDL_imageFilterBitAnd(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
49+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterBitAnd' {$ENDIF} {$ENDIF};
50+
51+
// SDL_imageFilterBitOr: D = S1 | S2
52+
function SDL_imageFilterBitOr(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
53+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterBitOr' {$ENDIF} {$ENDIF};
54+
55+
// SDL_imageFilterDiv: D = S1 / S2
56+
function SDL_imageFilterDiv(Src1, Src2, Dest: pcuint8; length: cuint): cint; cdecl;
57+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterDiv' {$ENDIF} {$ENDIF};
58+
59+
// SDL_imageFilterBitNegation: D = !S
60+
function SDL_imageFilterBitNegation(Src1, Dest: pcuint8; length: cuint): cint; cdecl;
61+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterBitNegation' {$ENDIF} {$ENDIF};
62+
63+
// SDL_imageFilterAddByte: D = saturation255(S + C)
64+
function SDL_imageFilterAddByte(Src1, Dest: pcuint8; length: cuint; C: cuint8): cint; cdecl;
65+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterAddByte' {$ENDIF} {$ENDIF};
66+
67+
// SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
68+
function SDL_imageFilterAddUint(Src1, Dest: pcuint8; length, bpp, C: cuint): cint; cdecl;
69+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterAddUint' {$ENDIF} {$ENDIF};
70+
71+
// SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
72+
function SDL_imageFilterAddByteToHalf(Src1, Dest: pcuint8; length: cuint; C: cuint8): cint; cdecl;
73+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterAddByteToHalf' {$ENDIF} {$ENDIF};
74+
75+
// SDL_imageFilterSubByte: D = saturation0(S - C)
76+
function SDL_imageFilterSubByte(Src1, Dest: pcuint8; length: cuint; C: cuint8): cint; cdecl;
77+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterSubByte' {$ENDIF} {$ENDIF};
78+
79+
// SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
80+
function SDL_imageFilterSubUint(Src1, Dest: pcuint8; length, bpp, C: cuint): cint; cdecl;
81+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterSubUint' {$ENDIF} {$ENDIF};
82+
83+
// SDL_imageFilterShiftRight: D = saturation0(S >> N)
84+
function SDL_imageFilterShiftRight(Src1, Dest: pcuint8; length: cuint; N: cuint8): cint; cdecl;
85+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftRight' {$ENDIF} {$ENDIF};
86+
87+
// SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
88+
function SDL_imageFilterShiftRightUint(Src1, Dest: pcuint8; length: cuint; N: cuint8): cint; cdecl;
89+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftRightUint' {$ENDIF} {$ENDIF};
90+
91+
// SDL_imageFilterMultByByte: D = saturation255(S * C)
92+
function SDL_imageFilterMultByByte(Src1, Dest: pcuint8; length: cuint; C: cuint8): cint; cdecl;
93+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterMultByByte' {$ENDIF} {$ENDIF};
94+
95+
// SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
96+
function SDL_imageFilterShiftRightAndMultByByte(Src1, Dest: pcuint8; length: cuint; N, C: cuint8): cint; cdecl;
97+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftRightAndMultByByte' {$ENDIF} {$ENDIF};
98+
99+
// SDL_imageFilterShiftLeftByte: D = (S << N)
100+
function SDL_imageFilterShiftLeftByte(Src1, Dest: pcuint8; length: cuint; N: cuint8): cint; cdecl;
101+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftLeftByte' {$ENDIF} {$ENDIF};
102+
103+
// SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
104+
function SDL_imageFilterShiftLeftUint(Src1, Dest: pcuint8; length: cuint; N: cuint8): cint; cdecl;
105+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftLeftUint' {$ENDIF} {$ENDIF};
106+
107+
// SDL_imageFilterShiftLeft: D = saturation255(S << N)
108+
function SDL_imageFilterShiftLeft(Src1, Dest: pcuint8; length: cuint; N: cuint8): cint; cdecl;
109+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterShiftLeft' {$ENDIF} {$ENDIF};
110+
111+
// SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
112+
function SDL_imageFilterBinarizeUsingThreshold(Src1, Dest: pcuint8; length: cuint; T: cuint8): cint; cdecl;
113+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterBinarizeUsingThreshold' {$ENDIF} {$ENDIF};
114+
115+
// SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
116+
function SDL_imageFilterClipToRange(Src1, Dest: pcuint8; length: cuint; Tmin, Tmax: cuint8): cint; cdecl;
117+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterClipToRange' {$ENDIF} {$ENDIF};
118+
119+
// SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
120+
function SDL_imageFilterNormalizeLinear(Src, Dest: pcuint8; length: cuint; Cmin, Cmax, Nmin, Nmax: cint): cint; cdecl;
121+
external GFX_LibName {$IFDEF DELPHI} {$IFDEF MACOS} name '_SDL_imageFilterNormalizeLinear' {$ENDIF} {$ENDIF};
122+

0 commit comments

Comments
 (0)