]> gitweb.factorcode.org Git - factor.git/blob - basis/gdk/pixbuf/ffi/ffi.factor
factor: more top level forms.
[factor.git] / basis / gdk / pixbuf / ffi / ffi.factor
1 ! Copyright (C) 2010 Anton Gorenko.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: alien alien.c-types alien.data alien.libraries
4 alien.syntax combinators gio.ffi glib.ffi gobject-introspection
5 gobject-introspection.standard-types kernel libc sequences
6 system vocabs ;
7 IN: gdk.pixbuf.ffi
8
9 << "gio.ffi" require >>
10
11 LIBRARY: gdk.pixbuf
12
13 LIBRARY-UNIX: gdk.pixbuf cdecl "libgdk_pixbuf-2.0.so"
14 LIBRARY-MACOSX: gdk.pixbuf cdecl "libgdk_pixbuf-2.0.dylib"
15 LIBRARY-WINDOWS: gdk.pixbuf cdecl "libgdk_pixbuf-2.0-0.dll"
16
17 GIR: vocab:gdk/pixbuf/GdkPixbuf-2.0.gir
18
19 ! <workaround incorrect return-values in gir
20
21 FORGET: gdk_pixbuf_get_pixels
22 FUNCTION: guint8* gdk_pixbuf_get_pixels ( GdkPixbuf* pixbuf )
23
24 FORGET: gdk_pixbuf_new_from_data
25 FUNCTION: GdkPixbuf* gdk_pixbuf_new_from_data ( guint8* data,
26                                                 GdkColorspace colorspace,
27                                                 gboolean has_alpha,
28                                                 int bits_per_sample,
29                                                 int width,
30                                                 int height,
31                                                 int rowstride,
32                                                 GdkPixbufDestroyNotify destroy_fn,
33                                                 gpointer destroy_fn_data )
34
35 FORGET: gdk_pixbuf_save_to_bufferv
36 FUNCTION: gboolean gdk_pixbuf_save_to_bufferv ( GdkPixbuf* pixbuf,
37                                                 guint8** data,
38                                                 gsize* buffer_size,
39                                                 c-string type,
40                                                 char **option_keys,
41                                                 char **option_values,
42                                                 GError **error )
43
44
45 ! workaround>
46
47 : data>GInputStream ( data -- GInputStream )
48     [ malloc-byte-array &free ] [ length ] bi
49     f g_memory_input_stream_new_from_data ;
50
51 : GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf )
52     f { { pointer: GError initial: f } }
53     [ gdk_pixbuf_new_from_stream ] with-out-parameters
54     handle-GError ;