| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | /*
 | 
					
						
							|  |  |  |  * This program is free software; you can redistribute it and/or | 
					
						
							|  |  |  |  * modify it under the terms of the GNU General Public License | 
					
						
							|  |  |  |  * as published by the Free Software Foundation; either version 2 | 
					
						
							|  |  |  |  * of the License, or (at your option) any later version. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is distributed in the hope that it will be useful, | 
					
						
							|  |  |  |  * but WITHOUT ANY WARRANTY; without even the implied warranty of | 
					
						
							|  |  |  |  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the | 
					
						
							|  |  |  |  * GNU General Public License for more details. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * You should have received a copy of the GNU General Public License | 
					
						
							|  |  |  |  * along with this program; if not, write to the Free Software Foundation, | 
					
						
							|  |  |  |  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-18 08:08:12 +11:00
										 |  |  | /** \file
 | 
					
						
							|  |  |  |  * \ingroup pygen | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  |  * | 
					
						
							|  |  |  |  * This file defines the 'imbuf' image manipulation module. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <Python.h>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-04 22:17:29 +10:00
										 |  |  | #include "BLI_rect.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include "BLI_string.h"
 | 
					
						
							|  |  |  | #include "BLI_utildefines.h"
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "py_capi_utils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include "python_utildefines.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | #include "imbuf_py_api.h" /* own include */
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | #include "../../imbuf/IMB_imbuf.h"
 | 
					
						
							|  |  |  | #include "../../imbuf/IMB_imbuf_types.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* File IO */ | 
					
						
							|  |  |  | #include "BLI_fileops.h"
 | 
					
						
							| 
									
										
										
										
											2020-03-19 09:33:03 +01:00
										 |  |  | #include <errno.h>
 | 
					
						
							|  |  |  | #include <fcntl.h>
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-26 09:30:18 +02:00
										 |  |  | static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Type & Utilities
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | typedef struct Py_ImBuf { | 
					
						
							| 
									
										
										
										
											2019-05-03 18:09:04 +10:00
										 |  |  |   PyObject_VAR_HEAD | 
					
						
							|  |  |  |       /* can be NULL */ | 
					
						
							|  |  |  |       ImBuf *ibuf; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } Py_ImBuf; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int py_imbuf_valid_check(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (LIKELY(self->ibuf)) { | 
					
						
							|  |  |  |     return 0; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-07 12:41:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   PyErr_Format( | 
					
						
							|  |  |  |       PyExc_ReferenceError, "ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name); | 
					
						
							|  |  |  |   return -1; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #define PY_IMBUF_CHECK_OBJ(obj) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \ | 
					
						
							|  |  |  |     return NULL; \ | 
					
						
							|  |  |  |   } \ | 
					
						
							|  |  |  |   ((void)0) | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | #define PY_IMBUF_CHECK_INT(obj) \
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \ | 
					
						
							|  |  |  |     return -1; \ | 
					
						
							|  |  |  |   } \ | 
					
						
							|  |  |  |   ((void)0) | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Methods
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(py_imbuf_resize_doc, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              ".. method:: resize(size, method='FAST')\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Resize the image.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :arg size: New size.\n" | 
					
						
							|  |  |  |              "   :type size: pair of ints\n" | 
					
						
							| 
									
										
										
										
											2019-10-01 04:12:12 +10:00
										 |  |  |              "   :arg method: Method of resizing ('FAST', 'BILINEAR')\n" | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              "   :type method: str\n"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   uint size[2]; | 
					
						
							| 
									
										
										
										
											2019-10-01 04:12:12 +10:00
										 |  |  | 
 | 
					
						
							|  |  |  |   enum { FAST, BILINEAR }; | 
					
						
							|  |  |  |   const struct PyC_StringEnumItems method_items[] = { | 
					
						
							|  |  |  |       {FAST, "FAST"}, | 
					
						
							|  |  |  |       {BILINEAR, "BILINEAR"}, | 
					
						
							|  |  |  |       {0, NULL}, | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  |   struct PyC_StringEnum method = {method_items, FAST}; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   static const char *_keywords[] = {"size", "method", NULL}; | 
					
						
							| 
									
										
										
										
											2019-10-01 04:12:12 +10:00
										 |  |  |   static _PyArg_Parser _parser = {"(II)|O&:resize", _keywords, 0}; | 
					
						
							|  |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast( | 
					
						
							|  |  |  |           args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-10-01 04:12:12 +10:00
										 |  |  |   if (method.value_found == FAST) { | 
					
						
							|  |  |  |     IMB_scalefastImBuf(self->ibuf, UNPACK2(size)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else if (method.value_found == BILINEAR) { | 
					
						
							|  |  |  |     IMB_scaleImBuf(self->ibuf, UNPACK2(size)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   else { | 
					
						
							|  |  |  |     BLI_assert(0); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-07-04 22:17:29 +10:00
										 |  |  | PyDoc_STRVAR(py_imbuf_crop_doc, | 
					
						
							|  |  |  |              ".. method:: crop(min, max)\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Crop the image.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :arg min: X, Y minimum.\n" | 
					
						
							|  |  |  |              "   :type min: pair of ints\n" | 
					
						
							|  |  |  |              "   :arg max: X, Y maximum.\n" | 
					
						
							|  |  |  |              "   :type max: pair of ints\n"); | 
					
						
							|  |  |  | static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   rcti crop; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   static const char *_keywords[] = {"min", "max", NULL}; | 
					
						
							|  |  |  |   static _PyArg_Parser _parser = {"(II)(II):crop", _keywords, 0}; | 
					
						
							|  |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast( | 
					
						
							|  |  |  |           args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax)) { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (/* X range. */ | 
					
						
							|  |  |  |       (!(crop.xmin >= 0 && crop.xmax < self->ibuf->x)) || | 
					
						
							|  |  |  |       /* Y range. */ | 
					
						
							|  |  |  |       (!(crop.ymin >= 0 && crop.ymax < self->ibuf->y)) || | 
					
						
							|  |  |  |       /* X order. */ | 
					
						
							|  |  |  |       (!(crop.xmin <= crop.xmax)) || | 
					
						
							|  |  |  |       /* Y order. */ | 
					
						
							|  |  |  |       (!(crop.ymin <= crop.ymax))) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_ValueError, "ImBuf crop min/max not in range"); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   IMB_rect_crop(self->ibuf, &crop); | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-26 09:30:18 +02:00
										 |  |  | PyDoc_STRVAR(py_imbuf_copy_doc, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              ".. method:: copy()\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :return: A copy of the image.\n" | 
					
						
							|  |  |  |              "   :rtype: :class:`ImBuf`\n"); | 
					
						
							| 
									
										
										
										
											2018-06-26 09:30:18 +02:00
										 |  |  | static PyObject *py_imbuf_copy(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   return Py_ImBuf_CreatePyObject(self->ibuf); | 
					
						
							| 
									
										
										
										
											2018-06-26 09:30:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (!PyC_CheckArgs_DeepCopy(args)) { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return py_imbuf_copy(self); | 
					
						
							| 
									
										
										
										
											2018-06-26 09:30:18 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | PyDoc_STRVAR(py_imbuf_free_doc, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              ".. method:: free()\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Clear image data immediately (causing an error on re-use).\n"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *py_imbuf_free(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (self->ibuf) { | 
					
						
							|  |  |  |     IMB_freeImBuf(self->ibuf); | 
					
						
							|  |  |  |     self->ibuf = NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static struct PyMethodDef Py_ImBuf_methods[] = { | 
					
						
							| 
									
										
										
										
											2019-07-04 21:10:06 +10:00
										 |  |  |     {"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, py_imbuf_resize_doc}, | 
					
						
							| 
									
										
										
										
											2019-07-04 22:17:29 +10:00
										 |  |  |     {"crop", (PyCFunction)py_imbuf_crop, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_crop_doc}, | 
					
						
							| 
									
										
										
										
											2019-07-04 21:10:06 +10:00
										 |  |  |     {"free", (PyCFunction)py_imbuf_free, METH_NOARGS, py_imbuf_free_doc}, | 
					
						
							|  |  |  |     {"copy", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc}, | 
					
						
							|  |  |  |     {"__copy__", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc}, | 
					
						
							|  |  |  |     {"__deepcopy__", (PyCFunction)py_imbuf_deepcopy, METH_VARARGS, py_imbuf_copy_doc}, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     {NULL, NULL, 0, NULL}, | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Attributes
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | PyDoc_STRVAR(py_imbuf_size_doc, "size of the image in pixels.\n\n:type: pair of ints"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   return PyC_Tuple_Pack_I32(ibuf->x, ibuf->y); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | PyDoc_STRVAR(py_imbuf_ppm_doc, "pixels per meter.\n\n:type: pair of floats"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   return PyC_Tuple_Pack_F64(ibuf->ppm[0], ibuf->ppm[1]); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PY_IMBUF_CHECK_INT(self); | 
					
						
							|  |  |  |   double ppm[2]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (PyC_AsArray(ppm, value, 2, &PyFloat_Type, true, "ppm") == -1) { | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (ppm[0] <= 0.0 || ppm[1] <= 0.0) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_ValueError, "invalid ppm value"); | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   ibuf->ppm[0] = ppm[0]; | 
					
						
							|  |  |  |   ibuf->ppm[1] = ppm[1]; | 
					
						
							|  |  |  |   return 0; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 10:31:17 +10:00
										 |  |  | PyDoc_STRVAR(py_imbuf_filepath_doc, "filepath associated with this image.\n\n:type: string"); | 
					
						
							|  |  |  | static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   return PyC_UnicodeFromByte(ibuf->name); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PY_IMBUF_CHECK_INT(self); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!PyUnicode_Check(value)) { | 
					
						
							|  |  |  |     PyErr_SetString(PyExc_TypeError, "expected a string!"); | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							| 
									
										
										
										
											2020-08-20 16:10:13 +10:00
										 |  |  |   const Py_ssize_t value_str_len_max = sizeof(ibuf->name); | 
					
						
							| 
									
										
										
										
											2019-09-16 10:31:17 +10:00
										 |  |  |   Py_ssize_t value_str_len; | 
					
						
							|  |  |  |   const char *value_str = _PyUnicode_AsStringAndSize(value, &value_str_len); | 
					
						
							|  |  |  |   if (value_str_len >= value_str_len_max) { | 
					
						
							|  |  |  |     PyErr_Format(PyExc_TypeError, "filepath length over %zd", value_str_len_max - 1); | 
					
						
							|  |  |  |     return -1; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   memcpy(ibuf->name, value_str, value_str_len + 1); | 
					
						
							|  |  |  |   return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-23 09:36:20 +10:00
										 |  |  | PyDoc_STRVAR(py_imbuf_planes_doc, "Number of bits associated with this image.\n\n:type: int"); | 
					
						
							|  |  |  | static PyObject *py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   ImBuf *imbuf = self->ibuf; | 
					
						
							|  |  |  |   return PyLong_FromLong(imbuf->planes); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(py_imbuf_channels_doc, "Number of bit-planes.\n\n:type: int"); | 
					
						
							|  |  |  | static PyObject *py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure)) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   PY_IMBUF_CHECK_OBJ(self); | 
					
						
							|  |  |  |   ImBuf *imbuf = self->ibuf; | 
					
						
							|  |  |  |   return PyLong_FromLong(imbuf->channels); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyGetSetDef Py_ImBuf_getseters[] = { | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"size", (getter)py_imbuf_size_get, (setter)NULL, py_imbuf_size_doc, NULL}, | 
					
						
							|  |  |  |     {"ppm", (getter)py_imbuf_ppm_get, (setter)py_imbuf_ppm_set, py_imbuf_ppm_doc, NULL}, | 
					
						
							|  |  |  |     {"filepath", | 
					
						
							| 
									
										
										
										
											2019-09-16 10:31:17 +10:00
										 |  |  |      (getter)py_imbuf_filepath_get, | 
					
						
							|  |  |  |      (setter)py_imbuf_filepath_set, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |      py_imbuf_filepath_doc, | 
					
						
							| 
									
										
										
										
											2019-09-16 10:31:17 +10:00
										 |  |  |      NULL}, | 
					
						
							| 
									
										
										
										
											2019-12-20 10:42:57 +11:00
										 |  |  |     {"planes", (getter)py_imbuf_planes_get, NULL, py_imbuf_planes_doc, NULL}, | 
					
						
							|  |  |  |     {"channels", (getter)py_imbuf_channels_get, NULL, py_imbuf_channels_doc, NULL}, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Type & Implementation
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static void py_imbuf_dealloc(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   if (ibuf != NULL) { | 
					
						
							|  |  |  |     IMB_freeImBuf(self->ibuf); | 
					
						
							|  |  |  |     self->ibuf = NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   PyObject_DEL(self); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *py_imbuf_repr(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   const ImBuf *ibuf = self->ibuf; | 
					
						
							|  |  |  |   if (ibuf != NULL) { | 
					
						
							|  |  |  |     return PyUnicode_FromFormat( | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |         "<imbuf: address=%p, filepath='%s', size=(%d, %d)>", ibuf, ibuf->name, ibuf->x, ibuf->y); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2020-08-07 12:41:06 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   return PyUnicode_FromString("<imbuf: address=0x0>"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static Py_hash_t py_imbuf_hash(Py_ImBuf *self) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return _Py_HashPointer(self->ibuf); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyTypeObject Py_ImBuf_Type = { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     PyVarObject_HEAD_INIT(NULL, 0) | 
					
						
							|  |  |  |     /*  For printing, in format "<module>.<name>" */ | 
					
						
							|  |  |  |     "ImBuf",          /* tp_name */ | 
					
						
							|  |  |  |     sizeof(Py_ImBuf), /* int tp_basicsize; */ | 
					
						
							|  |  |  |     0,                /* tp_itemsize;  For allocation */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Methods to implement standard operations */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     (destructor)py_imbuf_dealloc, /* destructor tp_dealloc; */ | 
					
						
							| 
									
										
										
										
											2019-10-16 14:44:36 +11:00
										 |  |  |     (printfunc)NULL,              /* printfunc tp_print; */ | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     NULL,                         /* getattrfunc tp_getattr; */ | 
					
						
							|  |  |  |     NULL,                         /* setattrfunc tp_setattr; */ | 
					
						
							|  |  |  |     NULL,                         /* cmpfunc tp_compare; */ | 
					
						
							|  |  |  |     (reprfunc)py_imbuf_repr,      /* reprfunc tp_repr; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Method suites for standard classes */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NULL, /* PyNumberMethods *tp_as_number; */ | 
					
						
							|  |  |  |     NULL, /* PySequenceMethods *tp_as_sequence; */ | 
					
						
							|  |  |  |     NULL, /* PyMappingMethods *tp_as_mapping; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* More standard operations (here for binary compatibility) */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     (hashfunc)py_imbuf_hash, /* hashfunc tp_hash; */ | 
					
						
							|  |  |  |     NULL,                    /* ternaryfunc tp_call; */ | 
					
						
							|  |  |  |     NULL,                    /* reprfunc tp_str; */ | 
					
						
							|  |  |  |     NULL,                    /* getattrofunc tp_getattro; */ | 
					
						
							|  |  |  |     NULL,                    /* setattrofunc tp_setattro; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* Functions to access object as input/output buffer */ | 
					
						
							|  |  |  |     NULL, /* PyBufferProcs *tp_as_buffer; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*** Flags to define presence of optional/expanded features ***/ | 
					
						
							|  |  |  |     Py_TPFLAGS_DEFAULT, /* long tp_flags; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     NULL, /*  char *tp_doc;  Documentation string */ | 
					
						
							|  |  |  |     /*** Assigned meaning in release 2.0 ***/ | 
					
						
							|  |  |  |     /* call function for all accessible objects */ | 
					
						
							|  |  |  |     NULL, /* traverseproc tp_traverse; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* delete references to contained objects */ | 
					
						
							|  |  |  |     NULL, /* inquiry tp_clear; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /***  Assigned meaning in release 2.1 ***/ | 
					
						
							|  |  |  |     /*** rich comparisons ***/ | 
					
						
							|  |  |  |     NULL, /* richcmpfunc tp_richcompare; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /***  weak reference enabler ***/ | 
					
						
							|  |  |  |     0, /* long tp_weaklistoffset; */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /*** Added in release 2.2 ***/ | 
					
						
							|  |  |  |     /*   Iterators */ | 
					
						
							|  |  |  |     NULL, /* getiterfunc tp_iter; */ | 
					
						
							|  |  |  |     NULL, /* iternextfunc tp_iternext; */ | 
					
						
							|  |  |  |     /*** Attribute descriptor and subclassing stuff ***/ | 
					
						
							|  |  |  |     Py_ImBuf_methods,   /* struct PyMethodDef *tp_methods; */ | 
					
						
							|  |  |  |     NULL,               /* struct PyMemberDef *tp_members; */ | 
					
						
							|  |  |  |     Py_ImBuf_getseters, /* struct PyGetSetDef *tp_getset; */ | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   Py_ImBuf *self = PyObject_New(Py_ImBuf, &Py_ImBuf_Type); | 
					
						
							|  |  |  |   self->ibuf = ibuf; | 
					
						
							|  |  |  |   return (PyObject *)self; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Module Functions
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(M_imbuf_new_doc, | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              ".. function:: new(size)\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   Load a new image.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :arg size: The size of the image in pixels.\n" | 
					
						
							|  |  |  |              "   :type size: pair of ints\n" | 
					
						
							|  |  |  |              "   :return: the newly loaded image.\n" | 
					
						
							|  |  |  |              "   :rtype: :class:`ImBuf`\n"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   int size[2]; | 
					
						
							|  |  |  |   static const char *_keywords[] = {"size", NULL}; | 
					
						
							|  |  |  |   static _PyArg_Parser _parser = {"(ii)|i:new", _keywords, 0}; | 
					
						
							|  |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &size[0], &size[1])) { | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /* TODO, make options */ | 
					
						
							| 
									
										
										
										
											2020-08-20 16:10:13 +10:00
										 |  |  |   const uchar planes = 4; | 
					
						
							|  |  |  |   const uint flags = IB_rect; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ImBuf *ibuf = IMB_allocImBuf(UNPACK2(size), planes, flags); | 
					
						
							|  |  |  |   if (ibuf == NULL) { | 
					
						
							|  |  |  |     PyErr_Format(PyExc_ValueError, "new: Unable to create image (%d, %d)", UNPACK2(size)); | 
					
						
							|  |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   return Py_ImBuf_CreatePyObject(ibuf); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(M_imbuf_load_doc, | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |              ".. function:: load(filepath)\n" | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              "\n" | 
					
						
							|  |  |  |              "   Load an image from a file.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |              "   :arg filepath: the filepath of the image.\n" | 
					
						
							|  |  |  |              "   :type filepath: string\n" | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              "   :return: the newly loaded image.\n" | 
					
						
							|  |  |  |              "   :rtype: :class:`ImBuf`\n"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   const char *filepath; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   static const char *_keywords[] = {"filepath", NULL}; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   static _PyArg_Parser _parser = {"s:load", _keywords, 0}; | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (file == -1) { | 
					
						
							| 
									
										
										
										
											2019-10-01 19:36:15 +02:00
										 |  |  |     PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", strerror(errno), filepath); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   ImBuf *ibuf = IMB_loadifffile(file, filepath, IB_rect, NULL, filepath); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   close(file); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (ibuf == NULL) { | 
					
						
							|  |  |  |     PyErr_Format( | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |         PyExc_ValueError, "load: Unable to recognize image format for file '%s'", filepath); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name)); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return Py_ImBuf_CreatePyObject(ibuf); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyDoc_STRVAR(M_imbuf_write_doc, | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |              ".. function:: write(image, filepath)\n" | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |              "\n" | 
					
						
							|  |  |  |              "   Write an image.\n" | 
					
						
							|  |  |  |              "\n" | 
					
						
							|  |  |  |              "   :arg image: the image to write.\n" | 
					
						
							|  |  |  |              "   :type image: :class:`ImBuf`\n" | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |              "   :arg filepath: the filepath of the image.\n" | 
					
						
							|  |  |  |              "   :type filepath: string\n"); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   Py_ImBuf *py_imb; | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   const char *filepath = NULL; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   static const char *_keywords[] = {"image", "filepath", NULL}; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   static _PyArg_Parser _parser = {"O!|s:write", _keywords, 0}; | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &Py_ImBuf_Type, &py_imb, &filepath)) { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |   if (filepath == NULL) { | 
					
						
							|  |  |  |     filepath = py_imb->ibuf->name; | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-08-20 16:10:13 +10:00
										 |  |  |   const bool ok = IMB_saveiff(py_imb->ibuf, filepath, IB_rect); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   if (ok == false) { | 
					
						
							|  |  |  |     PyErr_Format( | 
					
						
							| 
									
										
										
										
											2019-09-16 09:06:40 +10:00
										 |  |  |         PyExc_IOError, "write: Unable to write image file (%s) '%s'", strerror(errno), filepath); | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     return NULL; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Py_RETURN_NONE; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /* -------------------------------------------------------------------- */ | 
					
						
							|  |  |  | /** \name Module Definition
 | 
					
						
							|  |  |  |  * \{ */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static PyMethodDef IMB_methods[] = { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     {"new", (PyCFunction)M_imbuf_new, METH_VARARGS | METH_KEYWORDS, M_imbuf_new_doc}, | 
					
						
							|  |  |  |     {"load", (PyCFunction)M_imbuf_load, METH_VARARGS | METH_KEYWORDS, M_imbuf_load_doc}, | 
					
						
							|  |  |  |     {"write", (PyCFunction)M_imbuf_write, METH_VARARGS | METH_KEYWORDS, M_imbuf_write_doc}, | 
					
						
							|  |  |  |     {NULL, NULL, 0, NULL}, | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  | PyDoc_STRVAR(IMB_doc, "This module provides access to Blender's image manipulation API."); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | static struct PyModuleDef IMB_module_def = { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |     PyModuleDef_HEAD_INIT, | 
					
						
							|  |  |  |     "imbuf",     /* m_name */ | 
					
						
							|  |  |  |     IMB_doc,     /* m_doc */ | 
					
						
							|  |  |  |     0,           /* m_size */ | 
					
						
							|  |  |  |     IMB_methods, /* m_methods */ | 
					
						
							|  |  |  |     NULL,        /* m_reload */ | 
					
						
							|  |  |  |     NULL,        /* m_traverse */ | 
					
						
							|  |  |  |     NULL,        /* m_clear */ | 
					
						
							|  |  |  |     NULL,        /* m_free */ | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | PyObject *BPyInit_imbuf(void) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PyObject *submodule; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   submodule = PyModule_Create(&IMB_module_def); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   PyType_Ready(&Py_ImBuf_Type); | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-04-17 06:17:24 +02:00
										 |  |  |   return submodule; | 
					
						
							| 
									
										
										
										
											2018-06-07 07:41:49 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | /** \} */ |