]> gitweb.factorcode.org Git - factor.git/blob - basis/gdk/pixbuf/ffi/ffi.factor
Switch to https urls
[factor.git] / basis / gdk / pixbuf / ffi / ffi.factor
1 ! Copyright (C) 2010 Anton Gorenko.
2 ! See https://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 << "gdk.pixbuf" {
14     { [ os windows? ] [ "libgdk_pixbuf-2.0-0.dll" ] }
15     { [ os macosx? ] [ "libgdk_pixbuf-2.0.dylib" ] }
16     { [ os unix? ] [ "libgdk_pixbuf-2.0.so" ] }
17 } cond cdecl add-library >>
18
19 GIR: vocab:gdk/pixbuf/GdkPixbuf-2.0.gir
20
21 ! <workaround incorrect return-values in gir
22
23 FORGET: gdk_pixbuf_get_pixels
24 FUNCTION: guint8* gdk_pixbuf_get_pixels ( GdkPixbuf* pixbuf )
25
26 FORGET: gdk_pixbuf_new_from_data
27 FUNCTION: GdkPixbuf* gdk_pixbuf_new_from_data ( guint8* data,
28                                                 GdkColorspace colorspace,
29                                                 gboolean has_alpha,
30                                                 int bits_per_sample,
31                                                 int width,
32                                                 int height,
33                                                 int rowstride,
34                                                 GdkPixbufDestroyNotify destroy_fn,
35                                                 gpointer destroy_fn_data )
36
37 FORGET: gdk_pixbuf_save_to_bufferv
38 FUNCTION: gboolean gdk_pixbuf_save_to_bufferv ( GdkPixbuf* pixbuf,
39                                                 guint8** data,
40                                                 gsize* buffer_size,
41                                                 c-string type,
42                                                 char **option_keys,
43                                                 char **option_values,
44                                                 GError **error )
45
46
47 ! workaround>
48
49 : data>GInputStream ( data -- GInputStream )
50     [ malloc-byte-array &free ] [ length ] bi
51     f g_memory_input_stream_new_from_data ;
52
53 : GInputStream>GdkPixbuf ( GInputStream -- GdkPixbuf )
54     f { { pointer: GError initial: f } }
55     [ gdk_pixbuf_new_from_stream ] with-out-parameters
56     handle-GError ;