summary refs log tree commit diff stats
path: root/lib/wrappers/sdl/sdl_gfx.nim
blob: cf36c498948c55b91c20270222af5b3a1bbee467 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
#
#  $Id: sdl_gfx.pas,v 1.3 2007/05/29 21:31:04 savage Exp $
#
#
#
#  $Log: sdl_gfx.pas,v $
#  Revision 1.3  2007/05/29 21:31:04  savage
#  Changes as suggested by Almindor for 64bit compatibility.
#
#  Revision 1.2  2007/05/20 20:30:18  savage
#  Initial Changes to Handle 64 Bits
#
#  Revision 1.1  2005/01/03 19:08:32  savage
#  Header for the SDL_Gfx library.
#
#
#
#

import 
  sdl

when defined(windows): 
  const 
    gfxLibName = "SDL_gfx.dll"
elif defined(macosx): 
  const 
    gfxLibName = "libSDL_gfx.dylib"
else: 
  const 
    gfxLibName = "libSDL_gfx.so"
const                         # Some rates in Hz
  FPS_UPPER_LIMIT* = 200
  FPS_LOWER_LIMIT* = 1
  FPS_DEFAULT* = 30           # ---- Defines
  SMOOTHING_OFF* = 0
  SMOOTHING_ON* = 1

type 
  PFPSmanager* = ptr TFPSmanager
  TFPSmanager*{.final.} = object  # ---- Structures
    framecount*: Uint32
    rateticks*: float32
    lastticks*: Uint32
    rate*: Uint32

  PColorRGBA* = ptr TColorRGBA
  TColorRGBA*{.final.} = object 
    r*: byte
    g*: byte
    b*: byte
    a*: byte

  PColorY* = ptr TColorY
  TColorY*{.final.} = object  #
                              #
                              # SDL_framerate: framerate manager
                              #
                              # LGPL (c) A. Schiffler
                              #
                              #
    y*: byte


proc initFramerate*(manager: PFPSmanager){.cdecl, importc: "SDL_initFramerate", 
    dynlib: gfxLibName.}
proc setFramerate*(manager: PFPSmanager, rate: cint): cint{.cdecl, 
    importc: "SDL_setFramerate", dynlib: gfxLibName.}
proc getFramerate*(manager: PFPSmanager): cint{.cdecl, 
    importc: "SDL_getFramerate", dynlib: gfxLibName.}
proc framerateDelay*(manager: PFPSmanager){.cdecl, 
    importc: "SDL_framerateDelay", dynlib: gfxLibName.}
  #
  #
  # SDL_gfxPrimitives: graphics primitives for SDL
  #
  # LGPL (c) A. Schiffler
  #
  #
  # Note: all ___Color routines expect the color to be in format 0xRRGGBBAA 
  # Pixel 
proc pixelColor*(dst: PSurface, x: int16, y: int16, color: Uint32): cint{.
    cdecl, importc: "pixelColor", dynlib: gfxLibName.}
proc pixelRGBA*(dst: PSurface, x: int16, y: int16, r: byte, g: byte, 
                b: byte, a: byte): cint{.cdecl, importc: "pixelRGBA", 
    dynlib: gfxLibName.}
  # Horizontal line 
proc hlineColor*(dst: PSurface, x1: int16, x2: int16, y: int16, color: Uint32): cint{.
    cdecl, importc: "hlineColor", dynlib: gfxLibName.}
proc hlineRGBA*(dst: PSurface, x1: int16, x2: int16, y: int16, r: byte, 
                g: byte, b: byte, a: byte): cint{.cdecl, importc: "hlineRGBA", 
    dynlib: gfxLibName.}
  # Vertical line 
proc vlineColor*(dst: PSurface, x: int16, y1: int16, y2: int16, color: Uint32): cint{.
    cdecl, importc: "vlineColor", dynlib: gfxLibName.}
proc vlineRGBA*(dst: PSurface, x: int16, y1: int16, y2: int16, r: byte, 
                g: byte, b: byte, a: byte): cint{.cdecl, importc: "vlineRGBA", 
    dynlib: gfxLibName.}
  # Rectangle 
proc rectangleColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                     y2: int16, color: Uint32): cint{.cdecl, 
    importc: "rectangleColor", dynlib: gfxLibName.}
proc rectangleRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                    y2: int16, r: byte, g: byte, b: byte, a: byte): cint{.
    cdecl, importc: "rectangleRGBA", dynlib: gfxLibName.}
  # Filled rectangle (Box) 
proc boxColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
               color: Uint32): cint{.cdecl, importc: "boxColor", 
                                    dynlib: gfxLibName.}
proc boxRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
              r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "boxRGBA", dynlib: gfxLibName.}
  # Line 
proc lineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
                color: Uint32): cint{.cdecl, importc: "lineColor", 
                                     dynlib: gfxLibName.}
proc lineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
               r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "lineRGBA", dynlib: gfxLibName.}
  # AA Line 
proc aalineColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
                  color: Uint32): cint{.cdecl, importc: "aalineColor", 
                                       dynlib: gfxLibName.}
proc aalineRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "aalineRGBA", dynlib: gfxLibName.}
  # Circle 
proc circleColor*(dst: PSurface, x: int16, y: int16, r: int16, color: Uint32): cint{.
    cdecl, importc: "circleColor", dynlib: gfxLibName.}
proc circleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
                 g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "circleRGBA", dynlib: gfxLibName.}
  # AA Circle 
proc aacircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
                    color: Uint32): cint{.cdecl, importc: "aacircleColor", 
    dynlib: gfxLibName.}
proc aacircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, r: byte, 
                   g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "aacircleRGBA", dynlib: gfxLibName.}
  # Filled Circle 
proc filledCircleColor*(dst: PSurface, x: int16, y: int16, r: int16, 
                        color: Uint32): cint{.cdecl, 
    importc: "filledCircleColor", dynlib: gfxLibName.}
proc filledCircleRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
                       r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "filledCircleRGBA", dynlib: gfxLibName.}
  # Ellipse 
proc ellipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
                   color: Uint32): cint{.cdecl, importc: "ellipseColor", 
                                        dynlib: gfxLibName.}
proc ellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
                  r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "ellipseRGBA", dynlib: gfxLibName.}
  # AA Ellipse 
proc aaellipseColor*(dst: PSurface, xc: int16, yc: int16, rx: int16, 
                     ry: int16, color: Uint32): cint{.cdecl, 
    importc: "aaellipseColor", dynlib: gfxLibName.}
proc aaellipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, ry: int16, 
                    r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "aaellipseRGBA", dynlib: gfxLibName.}
  # Filled Ellipse 
proc filledEllipseColor*(dst: PSurface, x: int16, y: int16, rx: int16, 
                         ry: int16, color: Uint32): cint{.cdecl, 
    importc: "filledEllipseColor", dynlib: gfxLibName.}
proc filledEllipseRGBA*(dst: PSurface, x: int16, y: int16, rx: int16, 
                        ry: int16, r: byte, g: byte, b: byte, a: byte): cint{.
    cdecl, importc: "filledEllipseRGBA", dynlib: gfxLibName.}
  # Pie
proc pieColor*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
               finish: int16, color: Uint32): cint{.cdecl, importc: "pieColor", 
    dynlib: gfxLibName.}
proc pieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, start: int16, 
              finish: int16, r: byte, g: byte, b: byte, a: byte): cint{.
    cdecl, importc: "pieRGBA", dynlib: gfxLibName.}
  # Filled Pie
proc filledPieColor*(dst: PSurface, x: int16, y: int16, rad: int16, 
                     start: int16, finish: int16, color: Uint32): cint{.cdecl, 
    importc: "filledPieColor", dynlib: gfxLibName.}
proc filledPieRGBA*(dst: PSurface, x: int16, y: int16, rad: int16, 
                    start: int16, finish: int16, r: byte, g: byte, b: byte, 
                    a: byte): cint{.cdecl, importc: "filledPieRGBA", 
                                    dynlib: gfxLibName.}
  # Trigon
proc trigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
                  x3: int16, y3: int16, color: Uint32): cint{.cdecl, 
    importc: "trigonColor", dynlib: gfxLibName.}
proc trigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, y2: int16, 
                 x3: int16, y3: int16, r: byte, g: byte, b: byte, a: byte): cint{.
    cdecl, importc: "trigonRGBA", dynlib: gfxLibName.}
  # AA-Trigon
proc aatrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                    y2: int16, x3: int16, y3: int16, color: Uint32): cint{.
    cdecl, importc: "aatrigonColor", dynlib: gfxLibName.}
proc aatrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                   y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
                   b: byte, a: byte): cint{.cdecl, importc: "aatrigonRGBA", 
    dynlib: gfxLibName.}
  # Filled Trigon
proc filledTrigonColor*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                        y2: int16, x3: int16, y3: int16, color: Uint32): cint{.
    cdecl, importc: "filledTrigonColor", dynlib: gfxLibName.}
proc filledTrigonRGBA*(dst: PSurface, x1: int16, y1: int16, x2: int16, 
                       y2: int16, x3: int16, y3: int16, r: byte, g: byte, 
                       b: byte, a: byte): cint{.cdecl, 
    importc: "filledTrigonRGBA", dynlib: gfxLibName.}
  # Polygon
proc polygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
                   color: Uint32): cint{.cdecl, importc: "polygonColor", 
                                        dynlib: gfxLibName.}
proc polygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
                  g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "polygonRGBA", dynlib: gfxLibName.}
  # AA-Polygon
proc aapolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
                     color: Uint32): cint{.cdecl, importc: "aapolygonColor", 
    dynlib: gfxLibName.}
proc aapolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, r: byte, 
                    g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "aapolygonRGBA", dynlib: gfxLibName.}
  # Filled Polygon
proc filledPolygonColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
                         color: Uint32): cint{.cdecl, 
    importc: "filledPolygonColor", dynlib: gfxLibName.}
proc filledPolygonRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, 
                        r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "filledPolygonRGBA", dynlib: gfxLibName.}
  # Bezier
  # s = number of steps
proc bezierColor*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
                  color: Uint32): cint{.cdecl, importc: "bezierColor", 
                                       dynlib: gfxLibName.}
proc bezierRGBA*(dst: PSurface, vx: ptr int16, vy: ptr int16, n: cint, s: cint, 
                 r: byte, g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "bezierRGBA", dynlib: gfxLibName.}
  # Characters/Strings
proc characterColor*(dst: PSurface, x: int16, y: int16, c: char, color: Uint32): cint{.
    cdecl, importc: "characterColor", dynlib: gfxLibName.}
proc characterRGBA*(dst: PSurface, x: int16, y: int16, c: char, r: byte, 
                    g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "characterRGBA", dynlib: gfxLibName.}
proc stringColor*(dst: PSurface, x: int16, y: int16, c: cstring, color: Uint32): cint{.
    cdecl, importc: "stringColor", dynlib: gfxLibName.}
proc stringRGBA*(dst: PSurface, x: int16, y: int16, c: cstring, r: byte, 
                 g: byte, b: byte, a: byte): cint{.cdecl, 
    importc: "stringRGBA", dynlib: gfxLibName.}
proc gfxPrimitivesSetFont*(fontdata: Pointer, cw: cint, ch: cint){.cdecl, 
    importc: "gfxPrimitivesSetFont", dynlib: gfxLibName.}
  #
  #
  # SDL_imageFilter - bytes-image "filter" routines
  # (uses inline x86 MMX optimizations if available)
  #
  # LGPL (c) A. Schiffler
  #
  #
  # Comments:                                                                           
  #  1.) MMX functions work best if all data blocks are aligned on a 32 bytes boundary. 
  #  2.) Data that is not within an 8 byte boundary is processed using the C routine.   
  #  3.) Convolution routines do not have C routines at this time.                      
  # Detect MMX capability in CPU
proc imageFilterMMXdetect*(): cint{.cdecl, importc: "SDL_imageFilterMMXdetect", 
                                   dynlib: gfxLibName.}
  # Force use of MMX off (or turn possible use back on)
proc imageFilterMMXoff*(){.cdecl, importc: "SDL_imageFilterMMXoff", 
                           dynlib: gfxLibName.}
proc imageFilterMMXon*(){.cdecl, importc: "SDL_imageFilterMMXon", 
                          dynlib: gfxLibName.}
  #
  # All routines return:
  #   0   OK
  #  -1   Error (internal error, parameter error)
  #
  #  SDL_imageFilterAdd: D = saturation255(S1 + S2)
proc imageFilterAdd*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterAdd", dynlib: gfxLibName.}
  #  SDL_imageFilterMean: D = S1/2 + S2/2
proc imageFilterMean*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterMean", dynlib: gfxLibName.}
  #  SDL_imageFilterSub: D = saturation0(S1 - S2)
proc imageFilterSub*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterSub", dynlib: gfxLibName.}
  #  SDL_imageFilterAbsDiff: D = | S1 - S2 |
proc imageFilterAbsDiff*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterAbsDiff", dynlib: gfxLibName.}
  #  SDL_imageFilterMult: D = saturation(S1 * S2)
proc imageFilterMult*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterMult", dynlib: gfxLibName.}
  #  SDL_imageFilterMultNor: D = S1 * S2   (non-MMX)
proc imageFilterMultNor*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterMultNor", dynlib: gfxLibName.}
  #  SDL_imageFilterMultDivby2: D = saturation255(S1/2 * S2)
proc imageFilterMultDivby2*(Src1: cstring, Src2: cstring, Dest: cstring, 
                            len: cint): cint{.cdecl, 
    importc: "SDL_imageFilterMultDivby2", dynlib: gfxLibName.}
  #  SDL_imageFilterMultDivby4: D = saturation255(S1/2 * S2/2)
proc imageFilterMultDivby4*(Src1: cstring, Src2: cstring, Dest: cstring, 
                            len: cint): cint{.cdecl, 
    importc: "SDL_imageFilterMultDivby4", dynlib: gfxLibName.}
  #  SDL_imageFilterBitAnd: D = S1 & S2
proc imageFilterBitAnd*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterBitAnd", dynlib: gfxLibName.}
  #  SDL_imageFilterBitOr: D = S1 | S2
proc imageFilterBitOr*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterBitOr", dynlib: gfxLibName.}
  #  SDL_imageFilterDiv: D = S1 / S2   (non-MMX)
proc imageFilterDiv*(Src1: cstring, Src2: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterDiv", dynlib: gfxLibName.}
  #  SDL_imageFilterBitNegation: D = !S
proc imageFilterBitNegation*(Src1: cstring, Dest: cstring, len: cint): cint{.
    cdecl, importc: "SDL_imageFilterBitNegation", dynlib: gfxLibName.}
  #  SDL_imageFilterAddByte: D = saturation255(S + C)
proc imageFilterAddByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
    cdecl, importc: "SDL_imageFilterAddByte", dynlib: gfxLibName.}
  #  SDL_imageFilterAddUint: D = saturation255(S + (uint)C)
proc imageFilterAddUint*(Src1: cstring, Dest: cstring, len: cint, C: cint): cint{.
    cdecl, importc: "SDL_imageFilterAddUint", dynlib: gfxLibName.}
  #  SDL_imageFilterAddByteToHalf: D = saturation255(S/2 + C)
proc imageFilterAddByteToHalf*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
    cdecl, importc: "SDL_imageFilterAddByteToHalf", dynlib: gfxLibName.}
  #  SDL_imageFilterSubByte: D = saturation0(S - C)
proc imageFilterSubByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
    cdecl, importc: "SDL_imageFilterSubByte", dynlib: gfxLibName.}
  #  SDL_imageFilterSubUint: D = saturation0(S - (uint)C)
proc imageFilterSubUint*(Src1: cstring, Dest: cstring, len: cint, C: cint): cint{.
    cdecl, importc: "SDL_imageFilterSubUint", dynlib: gfxLibName.}
  #  SDL_imageFilterShiftRight: D = saturation0(S >> N)
proc imageFilterShiftRight*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
    cdecl, importc: "SDL_imageFilterShiftRight", dynlib: gfxLibName.}
  #  SDL_imageFilterShiftRightUint: D = saturation0((uint)S >> N)
proc imageFilterShiftRightUint*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
    cdecl, importc: "SDL_imageFilterShiftRightUint", dynlib: gfxLibName.}
  #  SDL_imageFilterMultByByte: D = saturation255(S * C)
proc imageFilterMultByByte*(Src1: cstring, Dest: cstring, len: cint, C: char): cint{.
    cdecl, importc: "SDL_imageFilterMultByByte", dynlib: gfxLibName.}
  #  SDL_imageFilterShiftRightAndMultByByte: D = saturation255((S >> N) * C)
proc imageFilterShiftRightAndMultByByte*(Src1: cstring, Dest: cstring, len: cint, 
    N: char, C: char): cint{.cdecl, 
                            importc: "SDL_imageFilterShiftRightAndMultByByte", 
                            dynlib: gfxLibName.}
  #  SDL_imageFilterShiftLeftByte: D = (S << N)
proc imageFilterShiftLeftByte*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
    cdecl, importc: "SDL_imageFilterShiftLeftByte", dynlib: gfxLibName.}
  #  SDL_imageFilterShiftLeftUint: D = ((uint)S << N)
proc imageFilterShiftLeftUint*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
    cdecl, importc: "SDL_imageFilterShiftLeftUint", dynlib: gfxLibName.}
  #  SDL_imageFilterShiftLeft: D = saturation255(S << N)
proc imageFilterShiftLeft*(Src1: cstring, Dest: cstring, len: cint, N: char): cint{.
    cdecl, importc: "SDL_imageFilterShiftLeft", dynlib: gfxLibName.}
  #  SDL_imageFilterBinarizeUsingThreshold: D = S >= T ? 255:0
proc imageFilterBinarizeUsingThreshold*(Src1: cstring, Dest: cstring, len: cint, 
                                        T: char): cint{.cdecl, 
    importc: "SDL_imageFilterBinarizeUsingThreshold", dynlib: gfxLibName.}
  #  SDL_imageFilterClipToRange: D = (S >= Tmin) & (S <= Tmax) 255:0
proc imageFilterClipToRange*(Src1: cstring, Dest: cstring, len: cint, Tmin: int8, 
                             Tmax: int8): cint{.cdecl, 
    importc: "SDL_imageFilterClipToRange", dynlib: gfxLibName.}
  #  SDL_imageFilterNormalizeLinear: D = saturation255((Nmax - Nmin)/(Cmax - Cmin)*(S - Cmin) + Nmin)
proc imageFilterNormalizeLinear*(Src1: cstring, Dest: cstring, len: cint, 
                                 Cmin: cint, Cmax: cint, Nmin: cint, Nmax: cint): cint{.
    cdecl, importc: "SDL_imageFilterNormalizeLinear", dynlib: gfxLibName.}
  # !!! NO C-ROUTINE FOR THESE FUNCTIONS YET !!! 
  #  SDL_imageFilterConvolveKernel3x3Divide: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel3x3Divide*(Src: cstring, Dest: cstring, rows: cint, 
    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel3x3Divide", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel5x5Divide: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel5x5Divide*(Src: cstring, Dest: cstring, rows: cint, 
    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel5x5Divide", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel7x7Divide: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel7x7Divide*(Src: cstring, Dest: cstring, rows: cint, 
    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel7x7Divide", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel9x9Divide: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel9x9Divide*(Src: cstring, Dest: cstring, rows: cint, 
    columns: cint, Kernel: pointer, Divisor: int8): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel9x9Divide", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel3x3ShiftRight: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel3x3ShiftRight*(Src: cstring, Dest: cstring, 
    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel3x3ShiftRight", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel5x5ShiftRight: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel5x5ShiftRight*(Src: cstring, Dest: cstring, 
    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel5x5ShiftRight", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel7x7ShiftRight: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel7x7ShiftRight*(Src: cstring, Dest: cstring, 
    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel7x7ShiftRight", dynlib: gfxLibName.}
  #  SDL_imageFilterConvolveKernel9x9ShiftRight: Dij = saturation0and255( ... )
proc imageFilterConvolveKernel9x9ShiftRight*(Src: cstring, Dest: cstring, 
    rows: cint, columns: cint, Kernel: pointer, NRightShift: char): cint{.cdecl, 
    importc: "SDL_imageFilterConvolveKernel9x9ShiftRight", dynlib: gfxLibName.}
  #  SDL_imageFilterSobelX: Dij = saturation255( ... )
proc imageFilterSobelX*(Src: cstring, Dest: cstring, rows: cint, columns: cint): cint{.
    cdecl, importc: "SDL_imageFilterSobelX", dynlib: gfxLibName.}
  #  SDL_imageFilterSobelXShiftRight: Dij = saturation255( ... )
proc imageFilterSobelXShiftRight*(Src: cstring, Dest: cstring, rows: cint, 
                                  columns: cint, NRightShift: char): cint{.cdecl, 
    importc: "SDL_imageFilterSobelXShiftRight", dynlib: gfxLibName.}
  # Align/restore stack to 32 byte boundary -- Functionality untested! --
proc imageFilterAlignStack*(){.cdecl, importc: "SDL_imageFilterAlignStack", 
                               dynlib: gfxLibName.}
proc imageFilterRestoreStack*(){.cdecl, importc: "SDL_imageFilterRestoreStack", 
                                 dynlib: gfxLibName.}
  #
  #
  # SDL_rotozoom - rotozoomer
  #
  # LGPL (c) A. Schiffler
  #
  #
  # 
  # 
  # rotozoomSurface()
  #
  # Rotates and zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  # 'angle' is the rotation in degrees. 'zoom' a scaling factor. If 'smooth' is 1
  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  #
  #
proc rotozoomSurface*(src: PSurface, angle: float64, zoom: float64, smooth: cint): PSurface{.
    cdecl, importc: "rotozoomSurface", dynlib: gfxLibName.}
proc rotozoomSurfaceXY*(src: PSurface, angle: float64, zoomx: float64, 
                        zoomy: float64, smooth: cint): PSurface{.cdecl, 
    importc: "rotozoomSurfaceXY", dynlib: gfxLibName.}
  # Returns the size of the target surface for a rotozoomSurface() call 
proc rotozoomSurfaceSize*(width: cint, height: cint, angle: float64, 
                          zoom: float64, dstwidth: var cint, dstheight: var cint){.
    cdecl, importc: "rotozoomSurfaceSize", dynlib: gfxLibName.}
proc rotozoomSurfaceSizeXY*(width: cint, height: cint, angle: float64, 
                            zoomx: float64, zoomy: float64, dstwidth: var cint, 
                            dstheight: var cint){.cdecl, 
    importc: "rotozoomSurfaceSizeXY", dynlib: gfxLibName.}
  #
  #
  # zoomSurface()
  #
  # Zoomes a 32bit or 8bit 'src' surface to newly created 'dst' surface.
  # 'zoomx' and 'zoomy' are scaling factors for width and height. If 'smooth' is 1
  # then the destination 32bit surface is anti-aliased. If the surface is not 8bit
  # or 32bit RGBA/ABGR it will be converted into a 32bit RGBA format on the fly.
  #
  #
proc zoomSurface*(src: PSurface, zoomx: float64, zoomy: float64, smooth: cint): PSurface{.
    cdecl, importc: "zoomSurface", dynlib: gfxLibName.}
  # Returns the size of the target surface for a zoomSurface() call 
proc zoomSurfaceSize*(width: cint, height: cint, zoomx: float64, zoomy: float64, 
                      dstwidth: var cint, dstheight: var cint){.cdecl, 
    importc: "zoomSurfaceSize", dynlib: gfxLibName.}
# implementation