Blender  V2.93
imbuf_py_api.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
23 #include <Python.h>
24 
25 #include "BLI_rect.h"
26 #include "BLI_string.h"
27 #include "BLI_utildefines.h"
28 
29 #include "py_capi_utils.h"
30 
31 #include "python_utildefines.h"
32 
33 #include "imbuf_py_api.h" /* own include */
34 
35 #include "../../imbuf/IMB_imbuf.h"
36 #include "../../imbuf/IMB_imbuf_types.h"
37 
38 /* File IO */
39 #include "BLI_fileops.h"
40 #include <errno.h>
41 #include <fcntl.h>
42 
43 static PyObject *BPyInit_imbuf_types(void);
44 
45 static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf);
46 
47 /* -------------------------------------------------------------------- */
51 typedef struct Py_ImBuf {
52  PyObject_VAR_HEAD
53  /* can be NULL */
56 
57 static int py_imbuf_valid_check(Py_ImBuf *self)
58 {
59  if (LIKELY(self->ibuf)) {
60  return 0;
61  }
62 
63  PyErr_Format(
64  PyExc_ReferenceError, "ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name);
65  return -1;
66 }
67 
68 #define PY_IMBUF_CHECK_OBJ(obj) \
69  if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \
70  return NULL; \
71  } \
72  ((void)0)
73 #define PY_IMBUF_CHECK_INT(obj) \
74  if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \
75  return -1; \
76  } \
77  ((void)0)
78 
81 /* -------------------------------------------------------------------- */
85 PyDoc_STRVAR(py_imbuf_resize_doc,
86  ".. method:: resize(size, method='FAST')\n"
87  "\n"
88  " Resize the image.\n"
89  "\n"
90  " :arg size: New size.\n"
91  " :type size: pair of ints\n"
92  " :arg method: Method of resizing ('FAST', 'BILINEAR')\n"
93  " :type method: str\n");
94 static PyObject *py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
95 {
96  PY_IMBUF_CHECK_OBJ(self);
97 
98  int size[2];
99 
100  enum { FAST, BILINEAR };
101  const struct PyC_StringEnumItems method_items[] = {
102  {FAST, "FAST"},
103  {BILINEAR, "BILINEAR"},
104  {0, NULL},
105  };
106  struct PyC_StringEnum method = {method_items, FAST};
107 
108  static const char *_keywords[] = {"size", "method", NULL};
109  static _PyArg_Parser _parser = {"(ii)|O&:resize", _keywords, 0};
110  if (!_PyArg_ParseTupleAndKeywordsFast(
111  args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) {
112  return NULL;
113  }
114  if (size[0] <= 0 || size[1] <= 0) {
115  PyErr_Format(PyExc_ValueError, "resize: Image size cannot be below 1 (%d, %d)", UNPACK2(size));
116  return NULL;
117  }
118 
119  if (method.value_found == FAST) {
121  }
122  else if (method.value_found == BILINEAR) {
123  IMB_scaleImBuf(self->ibuf, UNPACK2(size));
124  }
125  else {
127  }
128  Py_RETURN_NONE;
129 }
130 
131 PyDoc_STRVAR(py_imbuf_crop_doc,
132  ".. method:: crop(min, max)\n"
133  "\n"
134  " Crop the image.\n"
135  "\n"
136  " :arg min: X, Y minimum.\n"
137  " :type min: pair of ints\n"
138  " :arg max: X, Y maximum.\n"
139  " :type max: pair of ints\n");
140 static PyObject *py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
141 {
142  PY_IMBUF_CHECK_OBJ(self);
143 
144  rcti crop;
145 
146  static const char *_keywords[] = {"min", "max", NULL};
147  static _PyArg_Parser _parser = {"(II)(II):crop", _keywords, 0};
148  if (!_PyArg_ParseTupleAndKeywordsFast(
149  args, kw, &_parser, &crop.xmin, &crop.ymin, &crop.xmax, &crop.ymax)) {
150  return NULL;
151  }
152 
153  if (/* X range. */
154  (!(crop.xmin >= 0 && crop.xmax < self->ibuf->x)) ||
155  /* Y range. */
156  (!(crop.ymin >= 0 && crop.ymax < self->ibuf->y)) ||
157  /* X order. */
158  (!(crop.xmin <= crop.xmax)) ||
159  /* Y order. */
160  (!(crop.ymin <= crop.ymax))) {
161  PyErr_SetString(PyExc_ValueError, "ImBuf crop min/max not in range");
162  return NULL;
163  }
164  IMB_rect_crop(self->ibuf, &crop);
165  Py_RETURN_NONE;
166 }
167 
168 PyDoc_STRVAR(py_imbuf_copy_doc,
169  ".. method:: copy()\n"
170  "\n"
171  " :return: A copy of the image.\n"
172  " :rtype: :class:`ImBuf`\n");
173 static PyObject *py_imbuf_copy(Py_ImBuf *self)
174 {
175  PY_IMBUF_CHECK_OBJ(self);
176  ImBuf *ibuf_copy = IMB_dupImBuf(self->ibuf);
177 
178  if (UNLIKELY(ibuf_copy == NULL)) {
179  PyErr_SetString(PyExc_MemoryError,
180  "ImBuf.copy(): "
181  "failed to allocate memory memory");
182  return NULL;
183  }
184  return Py_ImBuf_CreatePyObject(ibuf_copy);
185 }
186 
187 static PyObject *py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
188 {
189  if (!PyC_CheckArgs_DeepCopy(args)) {
190  return NULL;
191  }
192  return py_imbuf_copy(self);
193 }
194 
195 PyDoc_STRVAR(py_imbuf_free_doc,
196  ".. method:: free()\n"
197  "\n"
198  " Clear image data immediately (causing an error on re-use).\n");
199 static PyObject *py_imbuf_free(Py_ImBuf *self)
200 {
201  if (self->ibuf) {
202  IMB_freeImBuf(self->ibuf);
203  self->ibuf = NULL;
204  }
205  Py_RETURN_NONE;
206 }
207 
208 static struct PyMethodDef Py_ImBuf_methods[] = {
209  {"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, py_imbuf_resize_doc},
210  {"crop", (PyCFunction)py_imbuf_crop, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_crop_doc},
211  {"free", (PyCFunction)py_imbuf_free, METH_NOARGS, py_imbuf_free_doc},
212  {"copy", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc},
213  {"__copy__", (PyCFunction)py_imbuf_copy, METH_NOARGS, py_imbuf_copy_doc},
214  {"__deepcopy__", (PyCFunction)py_imbuf_deepcopy, METH_VARARGS, py_imbuf_copy_doc},
215  {NULL, NULL, 0, NULL},
216 };
217 
220 /* -------------------------------------------------------------------- */
224 PyDoc_STRVAR(py_imbuf_size_doc, "size of the image in pixels.\n\n:type: pair of ints");
225 static PyObject *py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure))
226 {
227  PY_IMBUF_CHECK_OBJ(self);
228  ImBuf *ibuf = self->ibuf;
229  return PyC_Tuple_Pack_I32(ibuf->x, ibuf->y);
230 }
231 
232 PyDoc_STRVAR(py_imbuf_ppm_doc, "pixels per meter.\n\n:type: pair of floats");
233 static PyObject *py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure))
234 {
235  PY_IMBUF_CHECK_OBJ(self);
236  ImBuf *ibuf = self->ibuf;
237  return PyC_Tuple_Pack_F64(ibuf->ppm[0], ibuf->ppm[1]);
238 }
239 
240 static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
241 {
242  PY_IMBUF_CHECK_INT(self);
243  double ppm[2];
244 
245  if (PyC_AsArray(ppm, value, 2, &PyFloat_Type, true, "ppm") == -1) {
246  return -1;
247  }
248 
249  if (ppm[0] <= 0.0 || ppm[1] <= 0.0) {
250  PyErr_SetString(PyExc_ValueError, "invalid ppm value");
251  return -1;
252  }
253 
254  ImBuf *ibuf = self->ibuf;
255  ibuf->ppm[0] = ppm[0];
256  ibuf->ppm[1] = ppm[1];
257  return 0;
258 }
259 
260 PyDoc_STRVAR(py_imbuf_filepath_doc, "filepath associated with this image.\n\n:type: string");
261 static PyObject *py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure))
262 {
263  PY_IMBUF_CHECK_OBJ(self);
264  ImBuf *ibuf = self->ibuf;
265  return PyC_UnicodeFromByte(ibuf->name);
266 }
267 
268 static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
269 {
270  PY_IMBUF_CHECK_INT(self);
271 
272  if (!PyUnicode_Check(value)) {
273  PyErr_SetString(PyExc_TypeError, "expected a string!");
274  return -1;
275  }
276 
277  ImBuf *ibuf = self->ibuf;
278  const Py_ssize_t value_str_len_max = sizeof(ibuf->name);
279  Py_ssize_t value_str_len;
280  const char *value_str = PyUnicode_AsUTF8AndSize(value, &value_str_len);
281  if (value_str_len >= value_str_len_max) {
282  PyErr_Format(PyExc_TypeError, "filepath length over %zd", value_str_len_max - 1);
283  return -1;
284  }
285  memcpy(ibuf->name, value_str, value_str_len + 1);
286  return 0;
287 }
288 
289 PyDoc_STRVAR(py_imbuf_planes_doc, "Number of bits associated with this image.\n\n:type: int");
290 static PyObject *py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure))
291 {
292  PY_IMBUF_CHECK_OBJ(self);
293  ImBuf *imbuf = self->ibuf;
294  return PyLong_FromLong(imbuf->planes);
295 }
296 
297 PyDoc_STRVAR(py_imbuf_channels_doc, "Number of bit-planes.\n\n:type: int");
298 static PyObject *py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure))
299 {
300  PY_IMBUF_CHECK_OBJ(self);
301  ImBuf *imbuf = self->ibuf;
302  return PyLong_FromLong(imbuf->channels);
303 }
304 
305 static PyGetSetDef Py_ImBuf_getseters[] = {
306  {"size", (getter)py_imbuf_size_get, (setter)NULL, py_imbuf_size_doc, NULL},
307  {"ppm", (getter)py_imbuf_ppm_get, (setter)py_imbuf_ppm_set, py_imbuf_ppm_doc, NULL},
308  {"filepath",
309  (getter)py_imbuf_filepath_get,
310  (setter)py_imbuf_filepath_set,
311  py_imbuf_filepath_doc,
312  NULL},
313  {"planes", (getter)py_imbuf_planes_get, NULL, py_imbuf_planes_doc, NULL},
314  {"channels", (getter)py_imbuf_channels_get, NULL, py_imbuf_channels_doc, NULL},
315  {NULL, NULL, NULL, NULL, NULL} /* Sentinel */
316 };
317 
320 /* -------------------------------------------------------------------- */
324 static void py_imbuf_dealloc(Py_ImBuf *self)
325 {
326  ImBuf *ibuf = self->ibuf;
327  if (ibuf != NULL) {
328  IMB_freeImBuf(self->ibuf);
329  self->ibuf = NULL;
330  }
331  PyObject_DEL(self);
332 }
333 
334 static PyObject *py_imbuf_repr(Py_ImBuf *self)
335 {
336  const ImBuf *ibuf = self->ibuf;
337  if (ibuf != NULL) {
338  return PyUnicode_FromFormat(
339  "<imbuf: address=%p, filepath='%s', size=(%d, %d)>", ibuf, ibuf->name, ibuf->x, ibuf->y);
340  }
341 
342  return PyUnicode_FromString("<imbuf: address=0x0>");
343 }
344 
345 static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
346 {
347  return _Py_HashPointer(self->ibuf);
348 }
349 
350 PyTypeObject Py_ImBuf_Type = {
351  PyVarObject_HEAD_INIT(NULL, 0)
352  /* For printing, in format "<module>.<name>" */
353  "ImBuf", /* tp_name */
354  sizeof(Py_ImBuf), /* int tp_basicsize; */
355  0, /* tp_itemsize; For allocation */
356 
357  /* Methods to implement standard operations */
358 
359  (destructor)py_imbuf_dealloc, /* destructor tp_dealloc; */
360  0, /* tp_vectorcall_offset */
361  NULL, /* getattrfunc tp_getattr; */
362  NULL, /* setattrfunc tp_setattr; */
363  NULL, /* cmpfunc tp_compare; */
364  (reprfunc)py_imbuf_repr, /* reprfunc tp_repr; */
365 
366  /* Method suites for standard classes */
367 
368  NULL, /* PyNumberMethods *tp_as_number; */
369  NULL, /* PySequenceMethods *tp_as_sequence; */
370  NULL, /* PyMappingMethods *tp_as_mapping; */
371 
372  /* More standard operations (here for binary compatibility) */
373 
374  (hashfunc)py_imbuf_hash, /* hashfunc tp_hash; */
375  NULL, /* ternaryfunc tp_call; */
376  NULL, /* reprfunc tp_str; */
377  NULL, /* getattrofunc tp_getattro; */
378  NULL, /* setattrofunc tp_setattro; */
379 
380  /* Functions to access object as input/output buffer */
381  NULL, /* PyBufferProcs *tp_as_buffer; */
382 
383  /*** Flags to define presence of optional/expanded features ***/
384  Py_TPFLAGS_DEFAULT, /* long tp_flags; */
385 
386  NULL, /* char *tp_doc; Documentation string */
387  /*** Assigned meaning in release 2.0 ***/
388  /* call function for all accessible objects */
389  NULL, /* traverseproc tp_traverse; */
390 
391  /* delete references to contained objects */
392  NULL, /* inquiry tp_clear; */
393 
394  /*** Assigned meaning in release 2.1 ***/
395  /*** rich comparisons ***/
396  NULL, /* richcmpfunc tp_richcompare; */
397 
398  /*** weak reference enabler ***/
399  0, /* long tp_weaklistoffset; */
400 
401  /*** Added in release 2.2 ***/
402  /* Iterators */
403  NULL, /* getiterfunc tp_iter; */
404  NULL, /* iternextfunc tp_iternext; */
405  /*** Attribute descriptor and subclassing stuff ***/
406  Py_ImBuf_methods, /* struct PyMethodDef *tp_methods; */
407  NULL, /* struct PyMemberDef *tp_members; */
408  Py_ImBuf_getseters, /* struct PyGetSetDef *tp_getset; */
409 };
410 
411 static PyObject *Py_ImBuf_CreatePyObject(ImBuf *ibuf)
412 {
413  Py_ImBuf *self = PyObject_New(Py_ImBuf, &Py_ImBuf_Type);
414  self->ibuf = ibuf;
415  return (PyObject *)self;
416 }
417 
420 /* -------------------------------------------------------------------- */
424 PyDoc_STRVAR(M_imbuf_new_doc,
425  ".. function:: new(size)\n"
426  "\n"
427  " Load a new image.\n"
428  "\n"
429  " :arg size: The size of the image in pixels.\n"
430  " :type size: pair of ints\n"
431  " :return: the newly loaded image.\n"
432  " :rtype: :class:`ImBuf`\n");
433 static PyObject *M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
434 {
435  int size[2];
436  static const char *_keywords[] = {"size", NULL};
437  static _PyArg_Parser _parser = {"(ii):new", _keywords, 0};
438  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &size[0], &size[1])) {
439  return NULL;
440  }
441  if (size[0] <= 0 || size[1] <= 0) {
442  PyErr_Format(PyExc_ValueError, "new: Image size cannot be below 1 (%d, %d)", UNPACK2(size));
443  return NULL;
444  }
445 
446  /* TODO, make options */
447  const uchar planes = 4;
448  const uint flags = IB_rect;
449 
450  ImBuf *ibuf = IMB_allocImBuf(UNPACK2(size), planes, flags);
451  if (ibuf == NULL) {
452  PyErr_Format(PyExc_ValueError, "new: Unable to create image (%d, %d)", UNPACK2(size));
453  return NULL;
454  }
455  return Py_ImBuf_CreatePyObject(ibuf);
456 }
457 
458 PyDoc_STRVAR(M_imbuf_load_doc,
459  ".. function:: load(filepath)\n"
460  "\n"
461  " Load an image from a file.\n"
462  "\n"
463  " :arg filepath: the filepath of the image.\n"
464  " :type filepath: string\n"
465  " :return: the newly loaded image.\n"
466  " :rtype: :class:`ImBuf`\n");
467 static PyObject *M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
468 {
469  const char *filepath;
470 
471  static const char *_keywords[] = {"filepath", NULL};
472  static _PyArg_Parser _parser = {"s:load", _keywords, 0};
473  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &filepath)) {
474  return NULL;
475  }
476 
477  const int file = BLI_open(filepath, O_BINARY | O_RDONLY, 0);
478  if (file == -1) {
479  PyErr_Format(PyExc_IOError, "load: %s, failed to open file '%s'", strerror(errno), filepath);
480  return NULL;
481  }
482 
483  ImBuf *ibuf = IMB_loadifffile(file, filepath, IB_rect, NULL, filepath);
484 
485  close(file);
486 
487  if (ibuf == NULL) {
488  PyErr_Format(
489  PyExc_ValueError, "load: Unable to recognize image format for file '%s'", filepath);
490  return NULL;
491  }
492 
493  BLI_strncpy(ibuf->name, filepath, sizeof(ibuf->name));
494 
495  return Py_ImBuf_CreatePyObject(ibuf);
496 }
497 
498 PyDoc_STRVAR(M_imbuf_write_doc,
499  ".. function:: write(image, filepath)\n"
500  "\n"
501  " Write an image.\n"
502  "\n"
503  " :arg image: the image to write.\n"
504  " :type image: :class:`ImBuf`\n"
505  " :arg filepath: the filepath of the image.\n"
506  " :type filepath: string\n");
507 static PyObject *M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
508 {
509  Py_ImBuf *py_imb;
510  const char *filepath = NULL;
511 
512  static const char *_keywords[] = {"image", "filepath", NULL};
513  static _PyArg_Parser _parser = {"O!|s:write", _keywords, 0};
514  if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &Py_ImBuf_Type, &py_imb, &filepath)) {
515  return NULL;
516  }
517 
518  if (filepath == NULL) {
519  filepath = py_imb->ibuf->name;
520  }
521 
522  const bool ok = IMB_saveiff(py_imb->ibuf, filepath, IB_rect);
523  if (ok == false) {
524  PyErr_Format(
525  PyExc_IOError, "write: Unable to write image file (%s) '%s'", strerror(errno), filepath);
526  return NULL;
527  }
528 
529  Py_RETURN_NONE;
530 }
531 
534 /* -------------------------------------------------------------------- */
538 static PyMethodDef IMB_methods[] = {
539  {"new", (PyCFunction)M_imbuf_new, METH_VARARGS | METH_KEYWORDS, M_imbuf_new_doc},
540  {"load", (PyCFunction)M_imbuf_load, METH_VARARGS | METH_KEYWORDS, M_imbuf_load_doc},
541  {"write", (PyCFunction)M_imbuf_write, METH_VARARGS | METH_KEYWORDS, M_imbuf_write_doc},
542  {NULL, NULL, 0, NULL},
543 };
544 
545 PyDoc_STRVAR(IMB_doc, "This module provides access to Blender's image manipulation API.");
546 static struct PyModuleDef IMB_module_def = {
547  PyModuleDef_HEAD_INIT,
548  "imbuf", /* m_name */
549  IMB_doc, /* m_doc */
550  0, /* m_size */
551  IMB_methods, /* m_methods */
552  NULL, /* m_reload */
553  NULL, /* m_traverse */
554  NULL, /* m_clear */
555  NULL, /* m_free */
556 };
557 
558 PyObject *BPyInit_imbuf(void)
559 {
560  PyObject *mod;
561  PyObject *submodule;
562  PyObject *sys_modules = PyImport_GetModuleDict();
563 
564  mod = PyModule_Create(&IMB_module_def);
565 
566  /* `imbuf.types` */
567  PyModule_AddObject(mod, "types", (submodule = BPyInit_imbuf_types()));
568  PyDict_SetItem(sys_modules, PyModule_GetNameObject(submodule), submodule);
569 
570  return mod;
571 }
572 
575 /* -------------------------------------------------------------------- */
582 PyDoc_STRVAR(IMB_types_doc, "This module provides access to image buffer types.");
583 
584 static struct PyModuleDef IMB_types_module_def = {
585  PyModuleDef_HEAD_INIT,
586  "imbuf.types", /* m_name */
587  IMB_types_doc, /* m_doc */
588  0, /* m_size */
589  NULL, /* m_methods */
590  NULL, /* m_reload */
591  NULL, /* m_traverse */
592  NULL, /* m_clear */
593  NULL, /* m_free */
594 };
595 
596 PyObject *BPyInit_imbuf_types(void)
597 {
598  PyObject *submodule = PyModule_Create(&IMB_types_module_def);
599 
600  if (PyType_Ready(&Py_ImBuf_Type) < 0) {
601  return NULL;
602  }
603 
604  PyModule_AddType(submodule, &Py_ImBuf_Type);
605 
606  return submodule;
607 }
608 
#define BLI_assert_unreachable()
Definition: BLI_assert.h:96
File and directory operations.
int BLI_open(const char *filename, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
Definition: fileops.c:1017
#define O_BINARY
Definition: BLI_fileops.h:182
char * BLI_strncpy(char *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL()
Definition: string.c:108
unsigned char uchar
Definition: BLI_sys_types.h:86
unsigned int uint
Definition: BLI_sys_types.h:83
#define UNPACK2(a)
#define UNUSED(x)
#define UNLIKELY(x)
#define LIKELY(x)
bool IMB_scaleImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1667
struct ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, unsigned char planes, unsigned int flags)
Definition: allocimbuf.c:478
struct ImBuf * IMB_dupImBuf(const struct ImBuf *ibuf1)
void IMB_rect_crop(struct ImBuf *ibuf, const struct rcti *crop)
void IMB_freeImBuf(struct ImBuf *ibuf)
Definition: allocimbuf.c:211
struct ImBuf * IMB_loadifffile(int file, const char *filepath, int flags, char colorspace[IM_MAX_SPACE], const char *descr)
Definition: readimage.c:171
bool IMB_scalefastImBuf(struct ImBuf *ibuf, unsigned int newx, unsigned int newy)
Definition: scaling.c:1715
bool IMB_saveiff(struct ImBuf *ibuf, const char *filepath, int flags)
Definition: writeimage.c:44
@ IB_rect
PyObject * self
Definition: bpy_driver.c:185
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
FILE * file
static PyObject * py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:298
static PyObject * Py_ImBuf_CreatePyObject(ImBuf *ibuf)
Definition: imbuf_py_api.c:411
struct Py_ImBuf Py_ImBuf
static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
Definition: imbuf_py_api.c:268
PyDoc_STRVAR(py_imbuf_resize_doc, ".. method:: resize(size, method='FAST')\n" "\n" " Resize the image.\n" "\n" " :arg size: New size.\n" " :type size: pair of ints\n" " :arg method: Method of resizing ('FAST', 'BILINEAR')\n" " :type method: str\n")
static PyObject * py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:140
static PyObject * M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:507
static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
Definition: imbuf_py_api.c:345
#define PY_IMBUF_CHECK_OBJ(obj)
Definition: imbuf_py_api.c:68
static PyMethodDef IMB_methods[]
Definition: imbuf_py_api.c:538
static PyObject * py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:290
#define PY_IMBUF_CHECK_INT(obj)
Definition: imbuf_py_api.c:73
static PyObject * M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:467
static PyObject * py_imbuf_free(Py_ImBuf *self)
Definition: imbuf_py_api.c:199
static PyObject * py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:94
static PyObject * M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:433
static PyGetSetDef Py_ImBuf_getseters[]
Definition: imbuf_py_api.c:305
PyTypeObject Py_ImBuf_Type
Definition: imbuf_py_api.c:350
static PyObject * py_imbuf_copy(Py_ImBuf *self)
Definition: imbuf_py_api.c:173
static struct PyMethodDef Py_ImBuf_methods[]
Definition: imbuf_py_api.c:208
static struct PyModuleDef IMB_module_def
Definition: imbuf_py_api.c:546
static PyObject * py_imbuf_repr(Py_ImBuf *self)
Definition: imbuf_py_api.c:334
static struct PyModuleDef IMB_types_module_def
Definition: imbuf_py_api.c:584
static PyObject * BPyInit_imbuf_types(void)
Definition: imbuf_py_api.c:596
static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
Definition: imbuf_py_api.c:240
static int py_imbuf_valid_check(Py_ImBuf *self)
Definition: imbuf_py_api.c:57
static void py_imbuf_dealloc(Py_ImBuf *self)
Definition: imbuf_py_api.c:324
static PyObject * py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:233
static PyObject * py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
Definition: imbuf_py_api.c:187
static PyObject * py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:261
PyObject * BPyInit_imbuf(void)
Definition: imbuf_py_api.c:558
static PyObject * py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:225
int PyC_CheckArgs_DeepCopy(PyObject *args)
int PyC_ParseStringEnum(PyObject *o, void *p)
PyObject * PyC_UnicodeFromByte(const char *str)
int PyC_AsArray(void *array, PyObject *value, const Py_ssize_t length, const PyTypeObject *type, const bool is_double, const char *error_prefix)
#define PyC_Tuple_Pack_F64(...)
Definition: py_capi_utils.h:65
#define PyC_Tuple_Pack_I32(...)
Definition: py_capi_utils.h:67
header-only utilities
int channels
unsigned char planes
char name[IMB_FILENAME_SIZE]
double ppm[2]
PyObject_VAR_HEAD ImBuf * ibuf
Definition: imbuf_py_api.c:54
int ymin
Definition: DNA_vec_types.h:80
int ymax
Definition: DNA_vec_types.h:80
int xmin
Definition: DNA_vec_types.h:79
int xmax
Definition: DNA_vec_types.h:79
ccl_device_inline int mod(int x, int m)
Definition: util_math.h:405