Debian Codegraph @

swig/Fl_PNG_Image.i

raw
1 /* File : Fl_PNG_Image.i */
2 //%module Fl_PNG_Image
3
4 %feature("docstring") ::Fl_PNG_Image
5 """
6 The Fl_PNG_Image class supports loading, caching, and drawing of Portable
7 Network Graphics (PNG) image files. The class loads colormapped and
8 full-color images and handles color- and alpha-based transparency.
9 """ ;
10
11 %{
12 #include "FL/Fl_PNG_Image.H"
13 %}
14
15 //%include "macros.i"
16 //CHANGE_OWNERSHIP(Fl_PNG_Image)
17
18 %typemap(in) const unsigned char *buffer {
19 /* Check if the input support the buffer protocol */
20 Py_buffer view;
21 const void * buffer;
22 int failure = PyObject_GetBuffer($input, &view, PyBUF_CONTIG_RO);
23 if (!failure) {
24 // work with array object
25 buffer = view.buf;
26 PyBuffer_Release(&view);
27 $1 = (uchar *) buffer;
28 } else {
29 // work with list object
30 // clear the error from PyObject_GetBuffer
31 PyErr_Clear();
32 buffer=0;
33 /* Check if is a list */
34 if (PyList_Check($input)) {
35 Py_ssize_t size = PyList_Size($input);
36 int i = 0;
37 $1 = (uchar *) malloc((size+1)*sizeof(char));
38 for (i = 0; i < size; i++) {
39 PyObject *o = PyList_GetItem($input,i);
40 if (PyInt_Check(o))
41 $1[i] = (uchar)PyInt_AsLong(o);
42 else {
43 PyErr_SetString(PyExc_TypeError,"list must contain ints");
44 free($1);
45 return NULL;
46 }
47 }
48 $1[i] = 0;
49 } else {
50 PyErr_SetString(PyExc_TypeError,"not a list or does not support single-segment readable buffer interface");
51 return NULL;
52 }
53 }
54 }
55
56 %include "FL/Fl_PNG_Image.H"