/[gtk-cffi]/gtk-cffi/gdk/pixbuf.lisp
ViewVC logotype

Contents of /gtk-cffi/gdk/pixbuf.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations)
Sun Feb 12 17:29:41 2012 UTC (2 years, 2 months ago) by rklochkov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +2 -2 lines
Changed from cffi to cffi-objects
Dropped GTK-STRING
1 (in-package :gdk-cffi)
2
3 (defclass pixbuf (g-object)
4 ())
5
6 (defcfun "gdk_pixbuf_new" :pointer (colorspace :int) (has-alpha :boolean)
7 (bits-per-sample :int) (width :int) (height :int))
8
9 (defcfun "gdk_pixbuf_new_from_file" :pointer
10 (filename :string) (gerror pobject))
11
12 (defcfun "gdk_pixbuf_new_from_file_at_scale" :pointer
13 (filename :string) (width :int) (height :int)
14 (preserve-aspect :boolean) (gerror pobject))
15
16 (defcfun "gdk_pixbuf_new_subpixbuf" :pointer
17 (pixbuf pobject) (src-x :int) (src-y :int) (dst-x :int) (dst-y :int))
18
19 (defcfun "gdk_pixbuf_copy" :pointer
20 (pixbuf pobject))
21
22 (defgeneric new-from-image (image width height src-x src-y))
23
24 ;; (defcfun "gdk_pixbuf_get_from_image" :void (pixbuf pobject) (image pobject)
25 ;; (colormap pobject) (src-x :int) (src-y :int) (dst-x :int) (dst-y :int)
26 ;; (width :int) (height :int))
27
28 ;; (defcfun "gdk_pixbuf_get_from_drawable" :void (pixbuf pobject)
29 ;; (drawable pobject) (colormap pobject)
30 ;; (src-x :int) (src-y :int) (dst-x :int) (dst-y :int)
31 ;; (width :int) (height :int))
32
33 ;(defmethod new-from-image ((image image) width height src-x src-y)
34 ; (gdk-pixbuf-get-from-image (null-pointer) image (null-pointer)
35 ; src-x src-y 0 0 width height))
36
37 ;(defmethod new-from-image ((drawable drawable) width height src-x src-y)
38 ; (gdk-pixbuf-get-from-drawable (null-pointer) drawable (null-pointer)
39 ; src-x src-y 0 0 width height))
40
41 (defmethod gconstructor ((obj-pixbuf pixbuf)
42 &key file loader pixbuf
43 height width
44 has-alpha (bits-per-sample 8)
45 (preserve-aspect-ratio t)
46 src-x src-y
47 &allow-other-keys)
48 (declare (ignorable loader))
49 (cond
50 (file (with-g-error
51 g-error
52 (if (and width height)
53 (gdk-pixbuf-new-from-file-at-scale file
54 width height
55 preserve-aspect-ratio g-error)
56 (gdk-pixbuf-new-from-file file g-error))))
57
58 ;; from GdkImage or GdkDrawable
59 ; (image (new-from-image image width height src-x src-y))
60
61 ;(loader (new-from-loader loader))
62 (pixbuf
63 (if (and src-x src-y width height)
64 (gdk-pixbuf-new-subpixbuf pixbuf src-x src-y width height)
65 (gdk-pixbuf-copy pixbuf)))
66 (t (gdk-pixbuf-new 0 has-alpha bits-per-sample width height))))
67
68 (defcfun "gdk_pixbuf_get_width" :int (pixbuf pobject))
69 (defcfun "gdk_pixbuf_get_height" :int (pixbuf pobject))
70
71 (defmethod width ((pixbuf pixbuf))
72 (gdk-pixbuf-get-width pixbuf))
73
74 (defmethod height ((pixbuf pixbuf))
75 (gdk-pixbuf-get-height pixbuf))
76
77 (defcenum rgb-dither
78 :none :normal :max)
79
80 ;; (defcfun "gdk_draw_pixbuf" :void (drawable pobject) (gc pobject)
81 ;; (pixbuf pobject) (src-x :int) (src-y :int) (dst-x :int) (dst-y :int)
82 ;; (width :int) (height :int) (dither rgb-dither)
83 ;; (x-dither :int) (y-dither :int))
84
85 ;; (defmethod draw-pixbuf ((drawable drawable) (gc gc) (pixbuf pixbuf)
86 ;; &optional (src-x 0) (src-y 0)
87 ;; (dst-x 0) (dst-y 0) (width -1) (height -1)
88 ;; (dither :none) (x-dither 0) (y-dither 0))
89 ;; (gdk-draw-pixbuf drawable gc pixbuf src-x src-y dst-x dst-y
90 ;; width height dither x-dither y-dither))
91

  ViewVC Help
Powered by ViewVC 1.1.5