Blender  V3.3
Classes
imbuf_py_api.c File Reference
#include <Python.h>
#include "BLI_rect.h"
#include "BLI_string.h"
#include "BLI_utildefines.h"
#include "py_capi_utils.h"
#include "python_utildefines.h"
#include "imbuf_py_api.h"
#include "../../imbuf/IMB_imbuf.h"
#include "../../imbuf/IMB_imbuf_types.h"
#include "BLI_fileops.h"
#include <errno.h>
#include <fcntl.h>

Go to the source code of this file.

Classes

struct  Py_ImBuf
 

Functions

Module Functions
 PyDoc_STRVAR (M_imbuf_new_doc, ".. 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")
 
static PyObject * M_imbuf_new (PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (M_imbuf_load_doc, ".. function:: load(filepath)\n" "\n" " Load an image from a file.\n" "\n" " :arg filepath: the filepath of the image.\n" " :type filepath: string\n" " :return: the newly loaded image.\n" " :rtype: :class:`ImBuf`\n")
 
static PyObject * M_imbuf_load (PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 
 PyDoc_STRVAR (M_imbuf_write_doc, ".. function:: write(image, filepath=image.filepath)\n" "\n" " Write an image.\n" "\n" " :arg image: the image to write.\n" " :type image: :class:`ImBuf`\n" " :arg filepath: Optional filepath of the image (fallback to the images file path).\n" " :type filepath: string\n")
 
static PyObject * M_imbuf_write (PyObject *UNUSED(self), PyObject *args, PyObject *kw)
 

Type & Utilities

#define PY_IMBUF_CHECK_OBJ(obj)
 
#define PY_IMBUF_CHECK_INT(obj)
 
typedef struct Py_ImBuf Py_ImBuf
 
static int py_imbuf_valid_check (Py_ImBuf *self)
 

Methods

static struct PyMethodDef Py_ImBuf_methods []
 
 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_resize (Py_ImBuf *self, PyObject *args, PyObject *kw)
 
 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)
 
 PyDoc_STRVAR (py_imbuf_copy_doc, ".. method:: copy()\n" "\n" " :return: A copy of the image.\n" " :rtype: :class:`ImBuf`\n")
 
static PyObject * py_imbuf_copy (Py_ImBuf *self)
 
static PyObject * py_imbuf_deepcopy (Py_ImBuf *self, PyObject *args)
 
 PyDoc_STRVAR (py_imbuf_free_doc, ".. method:: free()\n" "\n" " Clear image data immediately (causing an error on re-use).\n")
 
static PyObject * py_imbuf_free (Py_ImBuf *self)
 

Attributes

static PyGetSetDef Py_ImBuf_getseters []
 
 PyDoc_STRVAR (py_imbuf_size_doc, "size of the image in pixels.\n\n:type: pair of ints")
 
static PyObject * py_imbuf_size_get (Py_ImBuf *self, void *UNUSED(closure))
 
 PyDoc_STRVAR (py_imbuf_ppm_doc, "pixels per meter.\n\n:type: pair of floats")
 
static PyObject * py_imbuf_ppm_get (Py_ImBuf *self, void *UNUSED(closure))
 
static int py_imbuf_ppm_set (Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
 
 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))
 
static int py_imbuf_filepath_set (Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
 
 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))
 
 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))
 

Type & Implementation

PyTypeObject Py_ImBuf_Type
 
static PyObject * Py_ImBuf_CreatePyObject (ImBuf *ibuf)
 
static void py_imbuf_dealloc (Py_ImBuf *self)
 
static PyObject * py_imbuf_repr (Py_ImBuf *self)
 
static Py_hash_t py_imbuf_hash (Py_ImBuf *self)
 

Module Definition (<tt>imbuf</tt>)

static PyMethodDef IMB_methods []
 
static struct PyModuleDef IMB_module_def
 
 PyDoc_STRVAR (IMB_doc, "This module provides access to Blender's image manipulation API.\n" "\n" "It provides access to image buffers outside of Blender's\n" ":class:`bpy.types.Image` data-block context.\n")
 
PyObject * BPyInit_imbuf (void)
 

Module Definition (<tt>imbuf.types</tt>)

imbuf.types module, only include this to expose access to imbuf.types.ImBuf for docs and the ability to use with built-ins such as isinstance, issubclass.

static struct PyModuleDef IMB_types_module_def
 
static PyObject * BPyInit_imbuf_types (void)
 
 PyDoc_STRVAR (IMB_types_doc, "This module provides access to image buffer types.\n" "\n" ".. note::\n" "\n" " Image buffer is also the structure used by :class:`bpy.types.Image`\n" " ID type to store and manipulate image data at runtime.\n")
 

Detailed Description

This file defines the 'imbuf' image manipulation module.

Definition in file imbuf_py_api.c.

Macro Definition Documentation

◆ PY_IMBUF_CHECK_INT

#define PY_IMBUF_CHECK_INT (   obj)
Value:
if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \
return -1; \
} \
((void)0)
#define UNLIKELY(x)
SyclQueue void void size_t num_bytes void
static int py_imbuf_valid_check(Py_ImBuf *self)
Definition: imbuf_py_api.c:43

Definition at line 59 of file imbuf_py_api.c.

◆ PY_IMBUF_CHECK_OBJ

#define PY_IMBUF_CHECK_OBJ (   obj)
Value:
if (UNLIKELY(py_imbuf_valid_check(obj) == -1)) { \
return NULL; \
} \
((void)0)

Definition at line 54 of file imbuf_py_api.c.

Typedef Documentation

◆ Py_ImBuf

typedef struct Py_ImBuf Py_ImBuf

Function Documentation

◆ BPyInit_imbuf()

PyObject* BPyInit_imbuf ( void  )

Definition at line 579 of file imbuf_py_api.c.

References BPyInit_imbuf_types(), IMB_module_def, and mod().

◆ BPyInit_imbuf_types()

PyObject * BPyInit_imbuf_types ( void  )
static

Definition at line 623 of file imbuf_py_api.c.

References IMB_types_module_def, NULL, and Py_ImBuf_Type.

Referenced by BPyInit_imbuf().

◆ M_imbuf_load()

static PyObject* M_imbuf_load ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

◆ M_imbuf_new()

static PyObject* M_imbuf_new ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

Definition at line 432 of file imbuf_py_api.c.

References IB_rect, IMB_allocImBuf(), NULL, Py_ImBuf_CreatePyObject(), size(), and UNPACK2.

◆ M_imbuf_write()

static PyObject* M_imbuf_write ( PyObject *  UNUSEDself,
PyObject *  args,
PyObject *  kw 
)
static

Definition at line 517 of file imbuf_py_api.c.

References IB_rect, Py_ImBuf::ibuf, IMB_saveiff(), ImBuf::name, NULL, and Py_ImBuf_Type.

◆ py_imbuf_channels_get()

static PyObject* py_imbuf_channels_get ( Py_ImBuf self,
void UNUSEDclosure 
)
static

Definition at line 297 of file imbuf_py_api.c.

References ImBuf::channels, and PY_IMBUF_CHECK_OBJ.

◆ py_imbuf_copy()

static PyObject* py_imbuf_copy ( Py_ImBuf self)
static

Definition at line 172 of file imbuf_py_api.c.

References IMB_dupImBuf(), NULL, PY_IMBUF_CHECK_OBJ, Py_ImBuf_CreatePyObject(), self, and UNLIKELY.

Referenced by py_imbuf_deepcopy().

◆ Py_ImBuf_CreatePyObject()

static PyObject * Py_ImBuf_CreatePyObject ( ImBuf ibuf)
static

Definition at line 410 of file imbuf_py_api.c.

References Py_ImBuf_Type.

Referenced by M_imbuf_load(), M_imbuf_new(), and py_imbuf_copy().

◆ py_imbuf_crop()

static PyObject* py_imbuf_crop ( Py_ImBuf self,
PyObject *  args,
PyObject *  kw 
)
static

◆ py_imbuf_dealloc()

static void py_imbuf_dealloc ( Py_ImBuf self)
static

Definition at line 323 of file imbuf_py_api.c.

References IMB_freeImBuf(), NULL, and self.

◆ py_imbuf_deepcopy()

static PyObject* py_imbuf_deepcopy ( Py_ImBuf self,
PyObject *  args 
)
static

Definition at line 186 of file imbuf_py_api.c.

References NULL, py_imbuf_copy(), and PyC_CheckArgs_DeepCopy().

◆ py_imbuf_filepath_get()

static PyObject* py_imbuf_filepath_get ( Py_ImBuf self,
void UNUSEDclosure 
)
static

Definition at line 260 of file imbuf_py_api.c.

References ImBuf::name, PY_IMBUF_CHECK_OBJ, and PyC_UnicodeFromByte().

◆ py_imbuf_filepath_set()

static int py_imbuf_filepath_set ( Py_ImBuf self,
PyObject *  value,
void UNUSEDclosure 
)
static

Definition at line 267 of file imbuf_py_api.c.

References ImBuf::name, and PY_IMBUF_CHECK_INT.

◆ py_imbuf_free()

static PyObject* py_imbuf_free ( Py_ImBuf self)
static

Definition at line 198 of file imbuf_py_api.c.

References IMB_freeImBuf(), NULL, and self.

◆ py_imbuf_hash()

static Py_hash_t py_imbuf_hash ( Py_ImBuf self)
static

Definition at line 344 of file imbuf_py_api.c.

References self.

◆ py_imbuf_planes_get()

static PyObject* py_imbuf_planes_get ( Py_ImBuf self,
void UNUSEDclosure 
)
static

Definition at line 289 of file imbuf_py_api.c.

References ImBuf::planes, and PY_IMBUF_CHECK_OBJ.

◆ py_imbuf_ppm_get()

static PyObject* py_imbuf_ppm_get ( Py_ImBuf self,
void UNUSEDclosure 
)
static

Definition at line 232 of file imbuf_py_api.c.

References ImBuf::ppm, PY_IMBUF_CHECK_OBJ, and PyC_Tuple_Pack_F64.

◆ py_imbuf_ppm_set()

static int py_imbuf_ppm_set ( Py_ImBuf self,
PyObject *  value,
void UNUSEDclosure 
)
static

Definition at line 239 of file imbuf_py_api.c.

References ImBuf::ppm, PY_IMBUF_CHECK_INT, and PyC_AsArray().

◆ py_imbuf_repr()

static PyObject* py_imbuf_repr ( Py_ImBuf self)
static

Definition at line 333 of file imbuf_py_api.c.

References ImBuf::name, NULL, ImBuf::x, and ImBuf::y.

◆ py_imbuf_resize()

static PyObject* py_imbuf_resize ( Py_ImBuf self,
PyObject *  args,
PyObject *  kw 
)
static

◆ py_imbuf_size_get()

static PyObject* py_imbuf_size_get ( Py_ImBuf self,
void UNUSEDclosure 
)
static

Definition at line 224 of file imbuf_py_api.c.

References PY_IMBUF_CHECK_OBJ, PyC_Tuple_Pack_I32, ImBuf::x, and ImBuf::y.

◆ py_imbuf_valid_check()

static int py_imbuf_valid_check ( Py_ImBuf self)
static

Definition at line 43 of file imbuf_py_api.c.

References LIKELY, and self.

◆ PyDoc_STRVAR() [1/14]

PyDoc_STRVAR ( IMB_doc  ,
"This module provides access to Blender's image manipulation API.\n" "\n" "It provides access to image buffers outside of Blender's\n" ":class:`bpy.types.Image` data-block context.\n"   
)

◆ PyDoc_STRVAR() [2/14]

PyDoc_STRVAR ( IMB_types_doc  ,
"This module provides access to image buffer types.\n" "\n" ".. note::\n" "\n" " Image buffer is also the structure used by :class:`bpy.types.Image`\n" " ID type to store and manipulate image data at runtime.\n"   
)

◆ PyDoc_STRVAR() [3/14]

PyDoc_STRVAR ( M_imbuf_load_doc  ,
".. function:: load(filepath)\n" "\n" " Load an image from a file.\n" "\n" " :arg filepath: the filepath of the image.\n" " :type filepath: string\n" " :return: the newly loaded image.\n" " :rtype: :class:`ImBuf`\n"   
)

◆ PyDoc_STRVAR() [4/14]

PyDoc_STRVAR ( M_imbuf_new_doc  ,
".. 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"   
)

◆ PyDoc_STRVAR() [5/14]

PyDoc_STRVAR ( M_imbuf_write_doc  ,
".. function:: write(image, filepath=image.filepath)\n" "\n" " Write an image.\n" "\n" " :arg image: the image to write.\n" " :type image: :class:`ImBuf`\n" " :arg filepath: Optional filepath of the image (fallback to the images file path).\n" " :type filepath: string\n"   
)

◆ PyDoc_STRVAR() [6/14]

PyDoc_STRVAR ( py_imbuf_channels_doc  ,
"Number of bit-planes.\n\n:type: int"   
)

◆ PyDoc_STRVAR() [7/14]

PyDoc_STRVAR ( py_imbuf_copy_doc  ,
".. method:: copy()\n" "\n" " :return: A copy of the image.\n" " :rtype: :class:`ImBuf`\n"   
)

◆ PyDoc_STRVAR() [8/14]

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"   
)

◆ PyDoc_STRVAR() [9/14]

PyDoc_STRVAR ( py_imbuf_filepath_doc  ,
"filepath associated with this image.\n\n:type: string"   
)

◆ PyDoc_STRVAR() [10/14]

PyDoc_STRVAR ( py_imbuf_free_doc  ,
".. method:: free()\n" "\n" " Clear image data immediately (causing an error on re-use).\n"   
)

◆ PyDoc_STRVAR() [11/14]

PyDoc_STRVAR ( py_imbuf_planes_doc  ,
"Number of bits associated with this image.\n\n:type: int"   
)

◆ PyDoc_STRVAR() [12/14]

PyDoc_STRVAR ( py_imbuf_ppm_doc  ,
"pixels per meter.\n\n:type: pair of floats"   
)

◆ PyDoc_STRVAR() [13/14]

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"   
)

◆ PyDoc_STRVAR() [14/14]

PyDoc_STRVAR ( py_imbuf_size_doc  ,
"size of the image in pixels.\n\n:type: pair of ints"   
)

Variable Documentation

◆ IMB_methods

PyMethodDef IMB_methods[]
static
Initial value:
= {
{"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},
}
static PyObject * M_imbuf_write(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:517
static PyObject * M_imbuf_load(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:471
static PyObject * M_imbuf_new(PyObject *UNUSED(self), PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:432

Definition at line 555 of file imbuf_py_api.c.

◆ IMB_module_def

struct PyModuleDef IMB_module_def
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"imbuf",
IMB_doc,
0,
NULL,
NULL,
NULL,
NULL,
}
static PyMethodDef IMB_methods[]
Definition: imbuf_py_api.c:555

Definition at line 562 of file imbuf_py_api.c.

Referenced by BPyInit_imbuf().

◆ IMB_types_module_def

struct PyModuleDef IMB_types_module_def
static
Initial value:
= {
PyModuleDef_HEAD_INIT,
"imbuf.types",
IMB_types_doc,
0,
NULL,
NULL,
NULL,
NULL,
NULL,
}

Definition at line 603 of file imbuf_py_api.c.

Referenced by BPyInit_imbuf_types().

◆ Py_ImBuf_getseters

PyGetSetDef Py_ImBuf_getseters[]
static
Initial value:
= {
{"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",
py_imbuf_filepath_doc,
NULL},
{"planes", (getter)py_imbuf_planes_get, NULL, py_imbuf_planes_doc, NULL},
{"channels", (getter)py_imbuf_channels_get, NULL, py_imbuf_channels_doc, NULL},
}
static PyObject * py_imbuf_channels_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:297
static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
Definition: imbuf_py_api.c:267
static PyObject * py_imbuf_planes_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:289
static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *UNUSED(closure))
Definition: imbuf_py_api.c:239
static PyObject * py_imbuf_ppm_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:232
static PyObject * py_imbuf_filepath_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:260
static PyObject * py_imbuf_size_get(Py_ImBuf *self, void *UNUSED(closure))
Definition: imbuf_py_api.c:224

Definition at line 304 of file imbuf_py_api.c.

◆ Py_ImBuf_methods

struct PyMethodDef Py_ImBuf_methods[]
static
Initial value:
= {
{"resize", (PyCFunction)py_imbuf_resize, METH_VARARGS | METH_KEYWORDS, py_imbuf_resize_doc},
{"crop", (PyCFunction)py_imbuf_crop, METH_VARARGS | METH_KEYWORDS, (char *)py_imbuf_crop_doc},
{"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},
{NULL, NULL, 0, NULL},
}
static PyObject * py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:133
static PyObject * py_imbuf_free(Py_ImBuf *self)
Definition: imbuf_py_api.c:198
static PyObject * py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
Definition: imbuf_py_api.c:80
static PyObject * py_imbuf_copy(Py_ImBuf *self)
Definition: imbuf_py_api.c:172
static PyObject * py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
Definition: imbuf_py_api.c:186

Definition at line 198 of file imbuf_py_api.c.

◆ Py_ImBuf_Type

PyTypeObject Py_ImBuf_Type

Definition at line 349 of file imbuf_py_api.c.

Referenced by BPyInit_imbuf_types(), M_imbuf_write(), and Py_ImBuf_CreatePyObject().