root/trunk/thirdparty/cl-gd-0.5.6/gd-uffi.lisp

Revision 2428, 16.8 kB (checked in by hhubner, 1 year ago)

Update cl-gd.

Line 
1 ;;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-GD; Base: 10 -*-
2 ;;; $Header: /usr/local/cvsrep/gd/gd-uffi.lisp,v 1.32 2007/04/05 23:22:24 edi Exp $
3
4 ;;; Copyright (c) 2003-2007, Dr. Edmund Weitz.  All rights reserved.
5
6 ;;; Redistribution and use in source and binary forms, with or without
7 ;;; modification, are permitted provided that the following conditions
8 ;;; are met:
9
10 ;;;   * Redistributions of source code must retain the above copyright
11 ;;;     notice, this list of conditions and the following disclaimer.
12
13 ;;;   * Redistributions in binary form must reproduce the above
14 ;;;     copyright notice, this list of conditions and the following
15 ;;;     disclaimer in the documentation and/or other materials
16 ;;;     provided with the distribution.
17
18 ;;; THIS SOFTWARE IS PROVIDED BY THE AUTHOR 'AS IS' AND ANY EXPRESSED
19 ;;; OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20 ;;; WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 ;;; ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
22 ;;; DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 ;;; DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
24 ;;; GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 ;;; INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
26 ;;; WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 ;;; NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 ;;; SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
30 (in-package :cl-gd)
31
32 ;; internal representation of an image in GD
33 (def-struct gd-image
34   (pixels (* (* :unsigned-char)))
35   (sx :int)
36   (sy :int)
37   (colors-total :int)
38   (red (:array :int #.+max-colors+))
39   (green (:array :int #.+max-colors+))
40   (blue (:array :int #.+max-colors+))
41   (open (:array :int #.+max-colors+))
42   (transparent :int)
43   (poly-ints (* :int))
44   (poly-allocated :int)
45   (brush :pointer-self)
46   (tile :pointer-self)
47   (brush-color-map (:array :int #.+max-colors+))
48   (tile-color-map (:array :int #.+max-colors+))
49   (style-length :int)
50   (style-pos :int)
51   (style (* :int))
52   (interface :int)
53   (thick :int)
54   (alpha (:array :int #.+max-colors+))
55   (true-color :int)
56   (t-pixels (* (* :int)))
57   (alpha-blending-flag :int)
58   (save-alpha-flag :int)
59   (aa :int)
60   (aa-color :int)
61   (aa-do-not-blend :int)
62   (aa-opacity (* (* :unsigned-char)))
63   (aa-polygon :int)
64   (aal-x1 :int)
65   (aal-y1 :int)
66   (aal-x2 :int)
67   (aal-y2 :int)
68   (aal-bx-ax :int)
69   (aal-by-ay :int)
70   (aal-lab-2 :int)
71   (aal-lab :float)
72   (cx1 :int)
73   (cy1 :int)
74   (cx2 :int)
75   (cy2 :int))
76
77 (def-type pixels-array (* (* :unsigned-char)))
78 (def-type pixels-row (* :unsigned-char))
79 (def-type t-pixels-array (* (* :int)))
80 (def-type t-pixels-row (* :int))
81
82 (def-foreign-type gd-image-ptr (* gd-image))
83
84 ;; initialize special variable
85 (setq *null-image* (make-image (make-null-pointer 'gd-image)))
86
87 ;; internal representation of a point in GD, used by the polygon
88 ;; functions
89 (def-struct gd-point
90   (x :int)
91   (y :int))
92
93 (def-foreign-type gd-point-ptr (* gd-point))
94
95 ;; internal representation of a font in GD, used by the (non-FreeType)
96 ;; functions which draw characters and strings
97 (def-struct gd-font
98   (nchars :int)
99   (offset :int)
100   (w :int)
101   (h :int)
102   (data (* :char)))
103
104 (def-foreign-type gd-font-ptr (* gd-font))
105
106 ;; additional info for calls to the FreeType library - currently only
107 ;; used for line spacing
108 (def-struct gd-ft-string-extra
109   (flags :int)
110   (line-spacing :double)
111   (charmap :int))
112
113 (def-foreign-type gd-ft-string-extra-ptr (* gd-ft-string-extra))
114
115 ;; the GD standard fonts used when drawing characters or strings
116 ;; without invoking the FreeType library
117 (def-foreign-var ("gdFontTiny" +gd-font-tiny+) gd-font-ptr "gd")
118 (def-foreign-var ("gdFontSmall" +gd-font-small+) gd-font-ptr "gd")
119 (def-foreign-var ("gdFontMediumBold" +gd-font-medium-bold+) gd-font-ptr "gd")
120 (def-foreign-var ("gdFontLarge" +gd-font-large+) gd-font-ptr "gd")
121 (def-foreign-var ("gdFontGiant" +gd-font-giant+) gd-font-ptr "gd")
122
123 ;;; all GD functions which are accessed from CL-GD
124
125 (def-function ("gdImageCreate" gd-image-create)
126     ((sx :int)
127      (sy :int))
128   :returning gd-image-ptr
129   :module "gd")
130
131 (def-function ("gdImageCreateTrueColor" gd-image-create-true-color)
132     ((sx :int)
133      (sy :int))
134   :returning gd-image-ptr
135   :module "gd")
136
137 (def-function ("gdImageCreateFromJpegFile" gd-image-create-from-jpeg-file)
138     ((filename :cstring)
139      (err (* :int)))
140   :returning gd-image-ptr
141   :module "gd")
142
143 (def-function ("gdImageCreateFromPngFile" gd-image-create-from-png-file)
144     ((filename :cstring)
145      (err (* :int)))
146   :returning gd-image-ptr
147   :module "gd")
148
149 (def-function ("gdImageCreateFromGdFile" gd-image-create-from-gd-file)
150     ((filename :cstring)
151      (err (* :int)))
152   :returning gd-image-ptr
153   :module "gd")
154
155 (def-function ("gdImageCreateFromGd2File" gd-image-create-from-gd2-file)
156     ((filename :cstring)
157      (err (* :int)))
158   :returning gd-image-ptr
159   :module "gd")
160
161 (def-function ("gdImageCreateFromGd2PartFile" gd-image-create-from-gd2-part-file)
162     ((filename :cstring)
163      (err (* :int))
164      (src-x :int)
165      (src-y :int)
166      (w :int)
167      (h :int))
168   :returning gd-image-ptr
169   :module "gd")
170
171 (def-function ("gdImageCreateFromXbmFile" gd-image-create-from-xbm-file)
172     ((filename :cstring)
173      (err (* :int)))
174   :returning gd-image-ptr
175   :module "gd")
176
177 #-:win32
178 (def-function ("gdImageCreateFromXpm" gd-image-create-from-xpm)
179     ((filename :cstring))
180   :returning gd-image-ptr
181   :module "gd")
182
183 #-:cl-gd-no-gif
184 (def-function ("gdImageCreateFromGifFile" gd-image-create-from-gif-file)
185     ((filename :cstring)
186      (err (* :int)))
187   :returning gd-image-ptr
188   :module "gd")
189
190 (def-function ("gdImageJpegPtr" gd-image-jpeg-ptr)
191     ((im gd-image-ptr)
192      (size (* :int))
193      (quality :int))
194   :returning :pointer-void
195   :module "gd")
196
197 (def-function ("gdImageGdPtr" gd-image-gd-ptr)
198     ((im gd-image-ptr)
199      (size (* :int)))
200   :returning :pointer-void
201   :module "gd")
202
203 (def-function ("gdImageGd2Ptr" gd-image-gd2-ptr)
204     ((im gd-image-ptr)
205      (size (* :int)))
206   :returning :pointer-void
207   :module "gd")
208
209 (def-function ("gdImageWBMPPtr" gd-image-wbmp-ptr)
210     ((im gd-image-ptr)
211      (size (* :int))
212      (fg :int))
213   :returning :pointer-void
214   :module "gd")
215
216 (def-function ("gdImagePngPtr" gd-image-png-ptr)
217     ((im gd-image-ptr)
218      (size (* :int)))
219   :returning :pointer-void
220   :module "gd")
221
222 (def-function ("gdImagePngPtrEx" gd-image-png-ptr-ex)
223     ((im gd-image-ptr)
224      (size (* :int))
225      (level :int))
226   :returning :pointer-void
227   :module "gd")
228
229 #-:cl-gd-no-gif
230 (def-function ("gdImageGifPtr" gd-image-gif-ptr)
231     ((im gd-image-ptr)
232      (size (* :int)))
233   :returning :pointer-void
234   :module "gd")
235
236 (def-function ("gdImageDestroy" gd-image-destroy)
237     ((im gd-image-ptr))
238   :returning :void
239   :module "gd")
240
241 (def-function ("gdImageColorAllocate" gd-image-color-allocate)
242     ((im gd-image-ptr)
243      (r :int)
244      (g :int)
245      (b :int))
246   :returning :int
247   :module "gd")
248
249 (def-function ("gdImageColorAllocateAlpha" gd-image-color-allocate-alpha)
250     ((im gd-image-ptr)
251      (r :int)
252      (g :int)
253      (b :int)
254      (a :int))
255   :returning :int
256   :module "gd")
257
258 (def-function ("gdImageColorDeallocate" gd-image-color-deallocate)
259     ((im gd-image-ptr)
260      (color :int))
261   :returning :void
262   :module "gd")
263
264 (def-function ("gdImageColorExact" gd-image-color-exact)
265     ((im gd-image-ptr)
266      (r :int)
267      (g :int)
268      (b :int))
269   :returning :int
270   :module "gd")
271
272 (def-function ("gdImageColorClosest" gd-image-color-closest)
273     ((im gd-image-ptr)
274      (r :int)
275      (g :int)
276      (b :int))
277   :returning :int
278   :module "gd")
279
280 (def-function ("gdImageColorClosestHWB" gd-image-color-closest-hwb)
281     ((im gd-image-ptr)
282      (r :int)
283      (g :int)
284      (b :int))
285   :returning :int
286   :module "gd")
287
288 (def-function ("gdImageColorClosestAlpha" gd-image-color-closest-alpha)
289     ((im gd-image-ptr)
290      (r :int)
291      (g :int)
292      (b :int)
293      (a :int))
294   :returning :int
295   :module "gd")
296
297 (def-function ("gdImageColorResolve" gd-image-color-resolve)
298     ((im gd-image-ptr)
299      (r :int)
300      (g :int)
301      (b :int))
302   :returning :int
303   :module "gd")
304
305 (def-function ("gdImageColorResolveAlpha" gd-image-color-resolve-alpha)
306     ((im gd-image-ptr)
307      (r :int)
308      (g :int)
309      (b :int)
310      (a :int))
311   :returning :int
312   :module "gd")
313
314 (def-function ("gdImageColorTransparent" gd-image-color-transparent)
315     ((im gd-image-ptr)
316      (color :int))
317   :returning :void
318   :module "gd")
319
320 (def-function ("gdImageGetGetTransparent" gd-image-get-transparent)
321     ((im gd-image-ptr))
322   :returning :int
323   :module "gd")
324
325 (def-function ("gdImageSetAntiAliased" gd-image-set-anti-aliased)
326     ((im gd-image-ptr)
327      (c :int))
328   :returning :void
329   :module "gd")
330
331 (def-function ("gdImageSetAntiAliasedDontBlend" gd-image-set-anti-aliased-do-not-blend)
332     ((im gd-image-ptr)
333      (c :int)
334      (dont-blend :int))
335   :returning :void
336   :module "gd")
337
338 (def-function ("gdImageSetBrush" gd-image-set-brush)
339     ((im gd-image-ptr)
340      (brush gd-image-ptr))
341   :returning :void
342   :module "gd")
343
344 (def-function ("gdImageSetTile" gd-image-set-tile)
345     ((im gd-image-ptr)
346      (tile gd-image-ptr))
347   :returning :void
348   :module "gd")
349
350 (def-function ("gdImageSetStyle" gd-image-set-style)
351     ((im gd-image-ptr)
352      (style (* :int))
353      (style-length :int))
354   :returning :void
355   :module "gd")
356
357 (def-function ("gdImageSetThickness" gd-image-set-thickness)
358     ((im gd-image-ptr)
359      (thickness :int))
360   :returning :void
361   :module "gd")
362
363 (def-function ("gdImageAlphaBlending" gd-image-alpha-blending)
364     ((im gd-image-ptr)
365      (blending :int))
366   :returning :void
367   :module "gd")
368
369 (def-function ("gdImageSaveAlpha" gd-image-save-alpha)
370     ((im gd-image-ptr)
371      (save-flag :int))
372   :returning :void
373   :module "gd")
374
375 (def-function ("gdImageGetRed" gd-image-get-red)
376     ((im gd-image-ptr)
377      (color :int))
378   :returning :int
379   :module "gd")
380
381 (def-function ("gdImageGetGreen" gd-image-get-green)
382     ((im gd-image-ptr)
383      (color :int))
384   :returning :int
385   :module "gd")
386
387 (def-function ("gdImageGetBlue" gd-image-get-blue)
388     ((im gd-image-ptr)
389      (color :int))
390   :returning :int
391   :module "gd")
392
393 (def-function ("gdImageGetAlpha" gd-image-get-alpha)
394     ((im gd-image-ptr)
395      (color :int))
396   :returning :int
397   :module "gd")
398
399 (def-function ("gdImageGetColorsTotal" gd-image-get-colors-total)
400     ((im gd-image-ptr))
401   :returning :int
402   :module "gd")
403
404 (def-function ("gdImageSetClip" gd-image-set-clip)
405     ((im gd-image-ptr)
406      (x1 :int)
407      (y1 :int)
408      (x2 :int)
409      (y2 :int))
410   :returning :void
411   :module "gd")
412
413 (def-function ("gdImageGetClip" gd-image-get-clip)
414     ((im gd-image-ptr)
415      (x1p (* :int))
416      (y1p (* :int))
417      (x2p (* :int))
418      (y2p (* :int)))
419   :returning :void
420   :module "gd")
421
422 (def-function ("gdImageSetPixel" gd-image-set-pixel)
423     ((im gd-image-ptr)
424      (x :int)
425      (y :int)
426      (color :int))
427   :returning :void
428   :module "gd")
429
430 (def-function ("gdImageLine" gd-image-line)
431     ((im gd-image-ptr)
432      (x1 :int)
433      (y1 :int)
434      (x2 :int)
435      (y2 :int)
436      (color :int))
437   :returning :void
438   :module "gd")
439
440 (def-function ("gdImagePolygon" gd-image-polygon)
441     ((im gd-image-ptr)
442      (points gd-point-ptr)
443      (points-total :int)
444      (color :int))
445   :returning :void
446   :module "gd")
447
448 (def-function ("gdImageFilledPolygon" gd-image-filled-polygon)
449     ((im gd-image-ptr)
450      (points gd-point-ptr)
451      (points-total :int)
452      (color :int))
453   :returning :void
454   :module "gd")
455
456 (def-function ("gdImageRectangle" gd-image-rectangle)
457     ((im gd-image-ptr)
458      (x1 :int)
459      (y1 :int)
460      (x2 :int)
461      (y2 :int)
462      (color :int))
463   :returning :void
464   :module "gd")
465
466 (def-function ("gdImageFilledRectangle" gd-image-filled-rectangle)
467     ((im gd-image-ptr)
468      (x1 :int)
469      (y1 :int)
470      (x2 :int)
471      (y2 :int)
472      (color :int))
473   :returning :void
474   :module "gd")
475
476 (def-function ("gdImageFilledEllipse" gd-image-filled-ellipse)
477     ((im gd-image-ptr)
478      (cx :int)
479      (cy :int)
480      (w :int)
481      (h :int)
482      (color :int))
483   :returning :void
484   :module "gd")
485
486 (def-function ("gdImageArc" gd-image-arc)
487     ((im gd-image-ptr)
488      (cx :int)
489      (cy :int)
490      (w :int)
491      (h :int)
492      (s :int)
493      (e :int)
494      (color :int))
495   :returning :void
496   :module "gd")
497
498 (def-function ("gdImageFilledArc" gd-image-filled-arc)
499     ((im gd-image-ptr)
500      (cx :int)
501      (cy :int)
502      (w :int)
503      (h :int)
504      (s :int)
505      (e :int)
506      (color :int)
507      (style :int))
508   :returning :void
509   :module "gd")
510
511 (def-function ("gdImageFill" gd-image-fill)
512     ((im gd-image-ptr)
513      (x :int)
514      (y :int)
515      (color :int))
516   :returning :void
517   :module "gd")
518
519 (def-function ("gdImageFillToBorder" gd-image-fill-to-border)
520     ((im gd-image-ptr)
521      (x :int)
522      (y :int)
523      (border :int)
524      (color :int))
525   :returning :void
526   :module "gd")
527
528 (def-function ("gdImageChar" gd-image-char)
529     ((im gd-image-ptr)
530      (f gd-font-ptr)
531      (x :int)
532      (y :int)
533      (c :int)
534      (color :int))
535   :returning :void
536   :module "gd")
537
538 (def-function ("gdImageCharUp" gd-image-char-up)
539     ((im gd-image-ptr)
540      (f gd-font-ptr)
541      (x :int)
542      (y :int)
543      (c :int)
544      (color :int))
545   :returning :void
546   :module "gd")
547
548 (def-function ("gdImageString" gd-image-string)
549     ((im gd-image-ptr)
550      (f gd-font-ptr)
551      (x :int)
552      (y :int)
553      (s :cstring)
554      (color :int))
555   :returning :void
556   :module "gd")
557
558 (def-function ("gdImageStringUp" gd-image-string-up)
559     ((im gd-image-ptr)
560      (f gd-font-ptr)
561      (x :int)
562      (y :int)
563      (s :cstring)
564      (color :int))
565   :returning :void
566   :module "gd")
567
568 (def-function ("gdImageStringFT" gd-image-string-ft)
569     ((im gd-image-ptr)
570      (brect (* :int))
571      (fg :int)
572      (fontname :cstring)
573      (ptsize :double)
574      (angle :double)
575      (x :int)
576      (y :int)
577      (string :cstring))
578   :returning :cstring
579   :module "gd")
580
581 (def-function ("gdImageStringFTEx" gd-image-string-ft-ex)
582     ((im gd-image-ptr)
583      (brect (* :int))
584      (fg :int)
585      (fontname :cstring)
586      (ptsize :double)
587      (angle :double)
588      (x :int)
589      (y :int)
590      (string :cstring)
591      (strex gd-ft-string-extra-ptr))
592   :returning :cstring
593   :module "gd")
594
595 (def-function ("gdImageGetPixel" gd-image-get-pixel)
596     ((im gd-image-ptr)
597      (x :int)
598      (y :int))
599   :returning :int
600   :module "gd")
601
602 (def-function ("gdImageBoundsSafe" gd-image-bounds-safe)
603     ((im gd-image-ptr)
604      (x :int)
605      (y :int))
606   :returning :int
607   :module "gd")
608
609 (def-function ("gdImageGetSX" gd-image-get-sx)
610     ((im gd-image-ptr))
611   :returning :int
612   :module "gd")
613
614 (def-function ("gdImageGetSY" gd-image-get-sy)
615     ((im gd-image-ptr))
616   :returning :int
617   :module "gd")
618
619 (def-function ("gdImageInterlace" gd-image-interlace)
620     ((im gd-image-ptr)
621      (interlace :int))
622   :returning :void
623   :module "gd")
624
625 (def-function ("gdImageGetGetInterlaced" gd-image-get-interlaced)
626     ((im gd-image-ptr))
627   :returning :int
628   :module "gd")
629
630 (def-function ("gdImageCopy" gd-image-copy)
631     ((dst gd-image-ptr)
632      (src gd-image-ptr)
633      (dest-x :int)
634      (dest-y :int)
635      (src-x :int)
636      (src-y :int)
637      (w :int)
638      (h :int))
639   :returning :void
640   :module "gd")
641
642 (def-function ("gdImageCopyMerge" gd-image-copy-merge)
643     ((dst gd-image-ptr)
644      (src gd-image-ptr)
645      (dest-x :int)
646      (dest-y :int)
647      (src-x :int)
648      (src-y :int)
649      (w :int)
650      (h :int)
651      (percent :int))
652   :returning :void
653   :module "gd")
654
655 (def-function ("gdImageCopyMergeGray" gd-image-copy-merge-gray)
656     ((dst gd-image-ptr)
657      (src gd-image-ptr)
658      (dest-x :int)
659      (dest-y :int)
660      (src-x :int)
661      (src-y :int)
662      (w :int)
663      (h :int)
664      (percent :int))
665   :returning :void
666   :module "gd")
667
668 (def-function ("gdImageCopyResized" gd-image-copy-resized)
669     ((dst gd-image-ptr)
670      (src gd-image-ptr)
671      (dst-x :int)
672      (dst-y :int)
673      (src-x :int)
674      (src-y :int)
675      (dest-w :int)
676      (dest-h :int)
677      (src-w :int)
678      (src-h :int))
679   :returning :void
680   :module "gd")
681
682 (def-function ("gdImageCopyResampled" gd-image-copy-resampled)
683     ((dst gd-image-ptr)
684      (src gd-image-ptr)
685      (dst-x :int)
686      (dst-y :int)
687      (src-x :int)
688      (src-y :int)
689      (dest-w :int)
690      (dest-h :int)
691      (src-w :int)
692      (src-h :int))
693   :returning :void
694   :module "gd")
695
696 (def-function ("gdImageCopyRotated" gd-image-copy-rotated)
697     ((dst gd-image-ptr)
698      (src gd-image-ptr)
699      (dst-x :double)
700      (dst-y :double)
701      (src-x :int)
702      (src-y :int)
703      (src-w :int)
704      (src-h :int)
705      (angle :int))
706   :returning :void
707   :module "gd")
708
709 (def-function ("gdImagePaletteCopy" gd-image-palette-copy)
710     ((dst gd-image-ptr)
711      (src gd-image-ptr))
712   :returning :void
713   :module "gd")
714
715 (def-function ("gdImageCompare" gd-image-compare)
716     ((im1 gd-image-ptr)
717      (im2 gd-image-ptr))
718   :returning :int
719   :module "gd")
720
721 (def-function ("gdImageTrueColorToPalette" gd-image-true-color-to-palette)
722     ((im gd-image-ptr)
723      (dither :int)
724      (colors-wanted :int))
725   :returning :void
726   :module "gd")
727
728 (def-function ("gdFree" gd-free)
729     ((ptr :pointer-void))
730   :returning :void
731   :module "gd")
Note: See TracBrowser for help on using the browser.