33#define IMB_FTYPE_DEFAULT IMB_FTYPE_PNG
43#define PY_IMBUF_BUFFER_TYPE_DOC \
44 " :param buffer_type: The buffer type.\n" \
45 " :type buffer_type: Literal['BYTE', 'FLOAT']\n"
106 if (self->
ibuf) [[likely]] {
111 PyExc_ReferenceError,
"ImBuf data of type %.200s has been freed", Py_TYPE(self)->tp_name);
115#define PY_IMBUF_CHECK_OBJ(obj) \
116 if (py_imbuf_valid_check(obj) == -1) [[unlikely]] { \
120#define PY_IMBUF_CHECK_INT(obj) \
121 if (py_imbuf_valid_check(obj) == -1) [[unlikely]] { \
126#define PY_IMBUF_CHECK_BUFFER_USERS_OBJ(obj) \
127 if ((obj)->buffer_users > 0) [[unlikely]] { \
128 PyErr_SetString(PyExc_BufferError, \
129 "ImBuf cannot be modified while pixel buffers are exported"); \
138 PyErr_WarnFormat(PyExc_RuntimeWarning, 1,
"unknown file type enum: %d", ftype);
152 if (
id ==
nullptr) [[unlikely]] {
175 return !((region->
xmin == 0 && region->
ymin == 0) &&
176 (region->
xmax == ibuf->
x && region->
ymax == ibuf->
y));
201 if (buffer_type == std::nullopt) [[unlikely]] {
202 PyErr_SetString(PyExc_ValueError,
"ImBuf has no pixel data");
220#define PY_IMBUF_CHECK_BUFFER_TYPE_OBJ(obj, buffer_type_var) \
221 PY_IMBUF_CHECK_OBJ(obj); \
222 const std::optional<ImBufFlags> _buffer_type_or_none = py_imbuf_buffer_type_or_error( \
224 if (_buffer_type_or_none == std::nullopt) [[unlikely]] { \
227 const ImBufFlags buffer_type_var = *(_buffer_type_or_none)
238 ".. method:: resize(size, *, method='FAST')\n"
240 " Resize the image in-place.\n"
242 " :param size: New size.\n"
243 " :type size: tuple[int, int]\n"
244 " :param method: Method of resizing ('FAST', 'BILINEAR').\n"
245 " :type method: str\n");
253 enum { FAST, BILINEAR };
256 {BILINEAR,
"BILINEAR"},
261 static const char *_keywords[] = {
266 static _PyArg_Parser _parser = {
274 if (!_PyArg_ParseTupleAndKeywordsFast(
279 if (size[0] <= 0 || size[1] <= 0) {
280 PyErr_Format(PyExc_ValueError,
"resize: Image size cannot be below 1 (%d, %d)",
UNPACK2(size));
299 ".. method:: crop(min, max)\n"
301 " Crop the image in-place.\n"
303 " :param min: Minimum pixel coordinates (X, Y), inclusive.\n"
304 " :type min: tuple[int, int]\n"
305 " :param max: Maximum pixel coordinates (X, Y), inclusive.\n"
306 " :type max: tuple[int, int]\n");
314 static const char *_keywords[] = {
319 static _PyArg_Parser _parser = {
326 if (!_PyArg_ParseTupleAndKeywordsFast(
341 PyErr_SetString(PyExc_ValueError,
"ImBuf crop min/max not in range");
354 ".. method:: copy()\n"
356 " Return a copy of the image.\n"
358 " :return: A copy of the image.\n"
359 " :rtype: :class:`ImBuf`\n");
365 if (ibuf_copy ==
nullptr) [[unlikely]] {
366 PyErr_SetString(PyExc_MemoryError,
368 "failed to allocate memory");
384 py_imbuf_with_buffer_doc,
385 ".. method:: with_buffer(*, write=False, region=None)\n"
387 " Return a context manager that yields a :class:`memoryview` "
388 "of the image's pixel data, shaped ``(height, width, channels)``.\n"
392 " with image.with_buffer(write=True) as buf:\n"
393 " buf[0, 0, 0] = 255 # set red channel of pixel (0, 0)\n"
395 " :param write: When true the buffer is writable.\n"
396 " :type write: bool\n"
397 " :param region: Optional sub-region ``((x_min, y_min), (x_max, y_max))``, "
398 "clamped to image bounds. When set the shape becomes "
399 "``(region_height, region_width, channels)``.\n"
400 " :type region: tuple[tuple[int, int], tuple[int, int]] | None\n"
401 " :return: A context manager yielding a :class:`memoryview` of pixel data.\n"
402 " :rtype: :class:`ImBufBuffer`\n");
408 std::optional<rcti> region;
410 static const char *_keywords[] = {
415 static _PyArg_Parser _parser = {
423 if (!_PyArg_ParseTupleAndKeywordsFast(
431 bool use_region =
false;
432 if (region.has_value()) {
437 if (ctx ==
nullptr) [[unlikely]] {
444 ctx->
region = use_region ? region : std::nullopt;
445 return reinterpret_cast<PyObject *
>(ctx);
450 py_imbuf_convert_buffer_type_doc,
451 ".. method:: convert_buffer_type(buffer_type)\n"
453 " Convert the image's pixel buffer to the given type.\n"
454 " When the image is already of the given type this is a no-op.\n"
455 " The previous buffer is freed.\n"
464 static const char *_keywords[] = {
468 static _PyArg_Parser _parser = {
470 ":convert_buffer_type",
474 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser,
PyC_ParseStringEnum, &buffer_type)) {
485 if (ibuf->
byte_data() ==
nullptr) [[unlikely]] {
486 PyErr_SetString(PyExc_MemoryError,
"failed to allocate byte buffer");
493 if (ibuf->
float_data() ==
nullptr) [[unlikely]] {
494 PyErr_SetString(PyExc_MemoryError,
"failed to allocate float buffer");
505 ".. method:: free()\n"
507 " Clear image data immediately (causing an error on re-use).\n");
513 self->
ibuf =
nullptr;
520# pragma clang diagnostic push
521# pragma clang diagnostic ignored "-Wcast-function-type"
523# pragma GCC diagnostic push
524# pragma GCC diagnostic ignored "-Wcast-function-type"
531 METH_VARARGS | METH_KEYWORDS,
532 py_imbuf_resize_doc},
535 METH_VARARGS | METH_KEYWORDS,
536 const_cast<char *
>(py_imbuf_crop_doc)},
539 METH_VARARGS | METH_KEYWORDS,
540 py_imbuf_with_buffer_doc},
541 {
"convert_buffer_type",
543 METH_VARARGS | METH_KEYWORDS,
544 py_imbuf_convert_buffer_type_doc},
545 {
"free",
reinterpret_cast<PyCFunction
>(
py_imbuf_free), METH_NOARGS, py_imbuf_free_doc},
546 {
"copy",
reinterpret_cast<PyCFunction
>(
py_imbuf_copy), METH_NOARGS, py_imbuf_copy_doc},
547 {
"__copy__",
reinterpret_cast<PyCFunction
>(
py_imbuf_copy), METH_NOARGS, py_imbuf_copy_doc},
552 {
nullptr,
nullptr, 0,
nullptr},
557# pragma clang diagnostic pop
559# pragma GCC diagnostic pop
572 "Size of the image in pixels.\n"
574 ":type: tuple[int, int]\n");
585 "Pixels per meter.\n"
587 ":type: tuple[float, float]\n");
600 if (
PyC_AsArray(ppm,
sizeof(*ppm), value, 2, &PyFloat_Type,
"ppm") == -1) {
604 if (ppm[0] <= 0.0 || ppm[1] <= 0.0) {
605 PyErr_SetString(PyExc_ValueError,
"invalid ppm value");
610 ibuf->
ppm[0] = ppm[0];
611 ibuf->
ppm[1] = ppm[1];
617 py_imbuf_filepath_doc,
618 "Filepath associated with this image.\n"
620 ":type: str | bytes\n");
633 const Py_ssize_t value_str_len_max =
FILE_MAX;
634 PyObject *value_coerce =
nullptr;
635 Py_ssize_t value_str_len;
637 if (value_str ==
nullptr) [[unlikely]] {
640 if (value_str_len >= value_str_len_max) {
641 PyErr_Format(PyExc_TypeError,
"filepath length over %zd", value_str_len_max - 1);
642 Py_XDECREF(value_coerce);
646 Py_XDECREF(value_coerce);
653 "Number of bits per pixel for the byte buffer.\n"
654 "Used when reading and writing image files.\n"
657 "- 16: Gray-scale with alpha.\n"
663 " This value may be set by the file format on load,\n"
664 " and determines how many channels are written on save.\n"
676 py_imbuf_channels_doc,
677 "Number of color channels.\n"
684 return PyLong_FromLong(
imbuf->channels);
689 py_imbuf_quality_doc,
690 "Quality for formats that support lossy compression (0 - 100, clamped).\n"
701 const int quality = PyC_Long_AsI32(value);
702 if (quality == -1 && PyErr_Occurred()) {
711 py_imbuf_compress_doc,
712 "Compression level for formats that support lossless compression levels (0 - 100, clamped).\n"
723 const int compress = PyC_Long_AsI32(value);
724 if (compress == -1 && PyErr_Occurred()) {
733 py_imbuf_file_type_doc,
734 "The file type identifier.\n"
741 return PyUnicode_FromString(
id);
747 const char *
str = PyUnicode_AsUTF8(value);
753 PyErr_Format(PyExc_ValueError,
"unknown file type: '%.200s'",
str);
762 py_imbuf_buffer_type_doc,
763 "Type of the image's pixel buffer (``'BYTE'`` or ``'FLOAT'``).\n"
769 return PyUnicode_FromString(
776 static_cast<setter
>(
nullptr),
787 py_imbuf_filepath_doc,
797 py_imbuf_channels_doc,
802 py_imbuf_file_type_doc,
807 py_imbuf_quality_doc,
812 py_imbuf_compress_doc,
817 py_imbuf_buffer_type_doc,
819 {
nullptr,
nullptr,
nullptr,
nullptr,
nullptr}
831 if (ibuf !=
nullptr) {
833 self->
ibuf =
nullptr;
841 if (ibuf !=
nullptr) {
842 return PyUnicode_FromFormat(
"<imbuf: address=%p, filepath='%s', size=(%d, %d)>",
849 return PyUnicode_FromString(
"<imbuf: address=0x0>");
858 PyVarObject_HEAD_INIT(
nullptr, 0)
914 return reinterpret_cast<PyObject *
>(self);
929 PyObject_GC_UnTrack(self);
931 PyObject_GC_Del(self);
955 if (ibuf !=
nullptr) {
956 return PyUnicode_FromFormat(
957 "<ImBufBuffer: size=(%d, %d), entered=%d>", ibuf->
x, ibuf->
y,
int(self->
is_entered));
959 return PyUnicode_FromString(
"<ImBufBuffer: invalid>");
965 PyErr_SetString(PyExc_RuntimeError,
"ImBufBuffer context is already entered");
973 const Py_ssize_t itemsize = is_byte ? 1 : Py_ssize_t(
sizeof(
float));
974 const char *format = is_byte ?
"B" :
"f";
977 std::optional<rcti> region_clamped = self->
region;
979 region_clamped.reset();
986 Py_ssize_t strides[3];
987 Py_ssize_t offset = 0;
989 if (region_clamped == std::nullopt) {
994 const rcti ®ion = *region_clamped;
995 shape[0] = region.
ymax - region.
ymin;
996 shape[1] = region.
xmax - region.
xmin;
997 offset = (Py_ssize_t(region.
ymin) * ibuf->
x + region.
xmin) * channels * itemsize;
1000 strides[0] = Py_ssize_t(ibuf->
x) * channels * itemsize;
1001 strides[1] = Py_ssize_t(channels) * itemsize;
1002 strides[2] = itemsize;
1005 memset(&pybuf, 0,
sizeof(pybuf));
1007 static_cast<void *
>(
1009 pybuf.len = shape[0] * shape[1] * shape[2] * itemsize;
1010 pybuf.itemsize = itemsize;
1012 pybuf.format =
const_cast<char *
>(format);
1014 pybuf.shape = shape;
1015 pybuf.strides = strides;
1016 PyObject *memview = PyMemoryView_FromBuffer(&pybuf);
1018 if (memview ==
nullptr) [[unlikely]] {
1039# pragma clang diagnostic push
1040# pragma clang diagnostic ignored "-Wcast-function-type"
1042# pragma GCC diagnostic push
1043# pragma GCC diagnostic ignored "-Wcast-function-type"
1050 {
nullptr,
nullptr, 0,
nullptr},
1055# pragma clang diagnostic pop
1057# pragma GCC diagnostic pop
1062 PyVarObject_HEAD_INIT(
nullptr, 0)
1075 PyObject_HashNotImplemented,
1081 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
1121 py_imbuf_file_type_id_doc,
1122 "The identifier for this image file type (e.g. ``\"PNG\"``, ``\"JPEG\"``).\n"
1128 return PyUnicode_FromString(
id);
1133 py_imbuf_file_type_file_extensions_doc,
1134 "The file extensions associated with this image file type (e.g. ``(\".jpg\", \".jpeg\")``).\n"
1136 ":type: tuple[str, ...]\n");
1141 return PyTuple_New(0);
1144 for (
const char **p = ext; *p; p++) {
1147 PyObject *tuple = PyTuple_New(
len);
1148 for (
int i = 0; i <
len; i++) {
1149 PyTuple_SET_ITEM(tuple, i, PyUnicode_FromString(ext[i]));
1170 py_imbuf_file_type_has_read_file_doc,
1171 "True when images of this file type can be read from a file.\n"
1177 py_imbuf_file_type_has_write_file_doc,
1178 "True when images of this file type can be written to a file.\n"
1184 py_imbuf_file_type_has_read_memory_doc,
1185 "True when images of this file type can be read from memory.\n"
1191 py_imbuf_file_type_has_write_memory_doc,
1192 "True when images of this file type can be written to memory.\n"
1200 py_imbuf_file_type_id_doc,
1205 py_imbuf_file_type_file_extensions_doc,
1210 py_imbuf_file_type_has_read_file_doc,
1215 py_imbuf_file_type_has_write_file_doc,
1220 py_imbuf_file_type_has_read_memory_doc,
1222 {
"has_write_memory",
1225 py_imbuf_file_type_has_write_memory_doc,
1233 return PyUnicode_FromFormat(
"<ImBufFileType: id='%s'>",
id);
1242 PyVarObject_HEAD_INIT(
nullptr, 0)
1302 ".. function:: new(size, *, planes=32, buffer_type='BYTE')\n"
1304 " Create a new image.\n"
1306 " :param size: The size of the image in pixels.\n"
1307 " :type size: tuple[int, int]\n"
1308 " :param planes: Number of bits per pixel.\n"
1310 " :return: The newly created image.\n"
1311 " :rtype: :class:`ImBuf`\n");
1312static PyObject *
M_imbuf_new(PyObject * , PyObject *args, PyObject *kw)
1317 static const char *_keywords[] = {
1323 static _PyArg_Parser _parser = {
1332 if (!_PyArg_ParseTupleAndKeywordsFast(
1337 if (size[0] <= 0 || size[1] <= 0) {
1338 PyErr_Format(PyExc_ValueError,
"new: Image size cannot be below 1 (%d, %d)",
UNPACK2(size));
1347 else if (planes == 16) {
1350 else if (planes == 24) {
1353 else if (planes == 32) {
1357 PyErr_Format(PyExc_ValueError,
"new: planes must be 8, 16, 24 or 32, got %d", planes);
1362 if (ibuf ==
nullptr) {
1363 PyErr_Format(PyExc_ValueError,
"new: Unable to create image (%d, %d)",
UNPACK2(size));
1374 PyErr_Format(PyExc_IOError,
"load: %s, failed to open file '%s'", strerror(errno), filepath);
1383 if (ibuf ==
nullptr) {
1385 PyExc_ValueError,
"load: Unable to recognize image format for file '%s'", filepath);
1397 ".. function:: load(filepath)\n"
1399 " Load an image from a file.\n"
1401 " :param filepath: The filepath of the image.\n"
1402 " :type filepath: str | bytes\n"
1403 " :return: The newly loaded image.\n"
1404 " :rtype: :class:`ImBuf`\n");
1409 static const char *_keywords[] = {
1413 static _PyArg_Parser _parser = {
1419 if (!_PyArg_ParseTupleAndKeywordsFast(
1431 const size_t buffer_size,
1435 reinterpret_cast<const uchar *
>(buffer), buffer_size, flags,
"<imbuf.load_from_buffer>");
1437 if (ibuf ==
nullptr) {
1438 PyErr_SetString(PyExc_ValueError,
"load_from_buffer: Unable to load image from memory");
1447 M_imbuf_load_from_buffer_doc,
1448 ".. function:: load_from_buffer(buffer)\n"
1450 " Load an image from a buffer.\n"
1452 " :param buffer: A buffer containing the image data.\n"
1453 " :type buffer: collections.abc.Buffer\n"
1454 " :return: The newly loaded image.\n"
1455 " :rtype: :class:`ImBuf`\n");
1458 PyObject *buffer_py_ob;
1460 static const char *_keywords[] = {
1464 static _PyArg_Parser _parser = {
1466 ":load_from_buffer",
1470 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &buffer_py_ob)) {
1474 PyObject *
result =
nullptr;
1478 if (PyObject_CheckBuffer(buffer_py_ob)) {
1480 if (PyObject_GetBuffer(buffer_py_ob, &pybuffer, PyBUF_SIMPLE) == -1) {
1484 reinterpret_cast<const char *
>(pybuffer.buf), pybuffer.len, flags);
1486 PyBuffer_Release(&pybuffer);
1489 PyErr_Format(PyExc_TypeError,
1490 "load_from_buffer: expected a buffer, unsupported type %.200s",
1491 Py_TYPE(buffer_py_ob)->tp_name);
1502 PyExc_IOError,
"write: Unable to write image file (%s) '%s'", strerror(errno), filepath);
1519 PyExc_ValueError,
"write: file type '%.200s' does not support writing to a file",
id);
1523 if (filepath_or_null ==
nullptr) {
1533 ".. function:: write(image, *, filepath=None)\n"
1535 " Write an image.\n"
1537 " :param image: The image to write.\n"
1538 " :type image: :class:`ImBuf`\n"
1539 " :param filepath: Optional filepath of the image (fallback to the image's file path).\n"
1540 " :type filepath: str | bytes | None\n");
1546 static const char *_keywords[] = {
1551 static _PyArg_Parser _parser = {
1559 if (!_PyArg_ParseTupleAndKeywordsFast(args,
1585 PyErr_SetString(PyExc_RuntimeError,
"write_to_buffer: failed to write image to memory");
1589 PyObject *memview = PyMemoryView_FromMemory(
1590 reinterpret_cast<char *
>(encoded.
data()), Py_ssize_t(encoded.
size()), PyBUF_READ);
1596 PyObject *
result = PyObject_CallMethod(file,
"write",
"O", memview);
1609 M_imbuf_write_to_buffer_doc,
1610 ".. function:: write_to_buffer(image, file)\n"
1612 " Write an image to a file-like object.\n"
1614 " :param image: The image to write.\n"
1615 " :type image: :class:`ImBuf`\n"
1616 " :param file: A writable file-like object (e.g. :class:`io.BytesIO`).\n"
1617 " :type file: :class:`BinaryIO`\n");
1623 static const char *_keywords[] = {
1628 static _PyArg_Parser _parser = {
1635 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &
Py_ImBuf_Type, &py_imb, &file)) {
1644 PyErr_Format(PyExc_ValueError,
1645 "write_to_buffer: file type '%.200s' does not support writing to memory",
1654 PyErr_SetString(PyExc_MemoryError,
"write_to_buffer: failed to duplicate image buffer");
1664 M_imbuf_file_type_from_buffer_doc,
1665 ".. function:: file_type_from_buffer(buffer)\n"
1667 " Detect the image file type from a buffer.\n"
1669 " :param buffer: A buffer containing image data.\n"
1670 " :type buffer: collections.abc.Buffer\n"
1671 " :return: The detected file type, or None if unrecognized.\n"
1672 " :rtype: :class:`ImBufFileType` | None\n");
1675 PyObject *buffer_py_ob;
1677 static const char *_keywords[] = {
1681 static _PyArg_Parser _parser = {
1683 ":file_type_from_buffer",
1687 if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &buffer_py_ob)) {
1691 if (!PyObject_CheckBuffer(buffer_py_ob)) {
1692 PyErr_Format(PyExc_TypeError,
1693 "file_type_from_buffer: expected a buffer, unsupported type %.200s",
1694 Py_TYPE(buffer_py_ob)->tp_name);
1699 if (PyObject_GetBuffer(buffer_py_ob, &pybuffer, PyBUF_SIMPLE) == -1) {
1703 reinterpret_cast<const uchar *
>(pybuffer.buf), pybuffer.len);
1704 PyBuffer_Release(&pybuffer);
1712 return reinterpret_cast<PyObject *
>(val);
1723# pragma clang diagnostic push
1724# pragma clang diagnostic ignored "-Wcast-function-type"
1726# pragma GCC diagnostic push
1727# pragma GCC diagnostic ignored "-Wcast-function-type"
1734 METH_VARARGS | METH_KEYWORDS,
1738 METH_VARARGS | METH_KEYWORDS,
1740 {
"load_from_buffer",
1742 METH_VARARGS | METH_KEYWORDS,
1743 M_imbuf_load_from_buffer_doc},
1746 METH_VARARGS | METH_KEYWORDS,
1750 METH_VARARGS | METH_KEYWORDS,
1751 M_imbuf_write_to_buffer_doc},
1752 {
"file_type_from_buffer",
1754 METH_VARARGS | METH_KEYWORDS,
1755 M_imbuf_file_type_from_buffer_doc},
1756 {
nullptr,
nullptr, 0,
nullptr},
1761# pragma clang diagnostic pop
1763# pragma GCC diagnostic pop
1770 "This module provides access to Blender's image manipulation API.\n"
1772 "It provides access to image buffers outside of Blender's\n"
1773 ":class:`bpy.types.Image` data-block context.\n");
1793 PyObject *submodule;
1794 PyObject *sys_modules = PyImport_GetModuleDict();
1811 PyDict_SetItemString(dict,
id,
reinterpret_cast<PyObject *
>(val));
1815 PyObject *proxy = PyDictProxy_New(dict);
1816 PyModule_AddObject(
mod,
"file_types", proxy);
1835 "This module provides access to image buffer types.\n"
1839 " Image buffer is also the structure used by :class:`bpy.types.Image`\n"
1840 " ID type to store and manipulate image data at runtime.\n");
1883 return (
reinterpret_cast<Py_ImBuf *
>(py_imbuf))->ibuf;
File and directory operations.
#define BLI_assert_unreachable()
#define POINTER_FROM_INT(i)
#define POINTER_AS_INT(i)
VecBase< float, D > constexpr mod(VecOp< float, D >, VecOp< float, D >) RET
#define PY_IMBUF_CHECK_BUFFER_USERS_OBJ(obj)
#define PY_IMBUF_BUFFER_TYPE_DOC
#define PY_IMBUF_CHECK_OBJ(obj)
#define IMB_FTYPE_DEFAULT
#define PY_IMBUF_CHECK_INT(obj)
#define PY_IMBUF_CHECK_BUFFER_TYPE_OBJ(obj, buffer_type_var)
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
static PyObject * M_imbuf_file_type_from_buffer(PyObject *, PyObject *args, PyObject *kw)
static const char * py_imbuf_type_none
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
eImbFileType IMB_ftype_from_id(const char *id)
const char ** IMB_ftype_file_extensions(eImbFileType ftype)
void IMB_free_byte_pixels(ImBuf *ibuf)
int PyC_ParseBool(PyObject *o, void *p)
static int py_imbuf_quality_set(Py_ImBuf *self, PyObject *value, void *)
static PyObject * py_imbuf_crop(Py_ImBuf *self, PyObject *args, PyObject *kw)
static PyGetSetDef Py_ImBufFileType_getseters[]
static PyObject * py_imbuf_quality_get(Py_ImBuf *self, void *)
PyTypeObject Py_ImBufFileType_Type
static PyObject * M_imbuf_write(PyObject *, PyObject *args, PyObject *kw)
static PyObject * M_imbuf_load_from_buffer(PyObject *, PyObject *args, PyObject *kw)
int PyC_CheckArgs_DeepCopy(PyObject *args)
static int py_imbuf_file_type_set(Py_ImBuf *self, PyObject *value, void *)
static PyObject * py_imbuf_buffer_exit(Py_ImBufBuffer *self, PyObject *)
static PyObject * imbuf_load_impl(const char *filepath)
Vector< uint8_t > IMB_save_image_to_buffer(ImBuf *ibuf, ImBufFlags flags)
static PyObject * py_imbuf_free(Py_ImBuf *self)
const char * IMB_ftype_to_id(eImbFileType ftype)
static Py_hash_t py_imbuf_file_type_hash(Py_ImBufFileType *self)
static PyObject * M_imbuf_write_to_buffer(PyObject *, PyObject *args, PyObject *kw)
PyDoc_STRVAR(bpy_bm_new_doc, ".. function:: new(*, use_operators=True)\n" "\n" " :param use_operators: Support calling operators in :mod:`bmesh.ops` (uses some " "extra memory per vert/edge/face).\n" " :type use_operators: bool\n" " :return: Return a new, empty BMesh.\n" " :rtype: :class:`bmesh.types.BMesh`\n")
int PyC_AsArray(void *array, const size_t array_item_size, PyObject *value, const Py_ssize_t length, const PyTypeObject *type, const char *error_prefix)
static PyObject * BPyInit_imbuf_types()
PyTypeObject Py_ImBuf_Type
static PyObject * py_imbuf_size_get(Py_ImBuf *self, void *)
static PyObject * py_imbuf_with_buffer(Py_ImBuf *self, PyObject *args, PyObject *kw)
static std::optional< ImBufFlags > py_imbuf_buffer_type_or_error(const ImBuf *ibuf)
int BLI_open(const char *filepath, int oflag, int pmode) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
static PyObject * py_imbuf_compress_get(Py_ImBuf *self, void *)
static PyObject * py_imbuf_planes_get(Py_ImBuf *self, void *)
PyObject * PyC_Tuple_Pack_F64(const Span< double > values)
void BLI_rcti_sanitize(struct rcti *rect)
static void py_imbuf_warn_corrupt_ftype(const eImbFileType ftype)
void IMB_crop(ImBuf *ibuf, const int2 &rect_pos, const int2 &rect_size)
ImBuf * IMB_dupImBuf(const ImBuf *ibuf1)
static PyObject * py_imbuf_deepcopy(Py_ImBuf *self, PyObject *args)
PyObject * PyC_Tuple_Pack_I32(const Span< int > values)
static ImBufFlags py_imbuf_write_flags(const ImBuf *ibuf)
bool IMB_save_image(ImBuf *ibuf, const char *filepath, ImBufFlags flags)
void IMB_float_from_byte(ImBuf *ibuf)
static PyObject * M_imbuf_new(PyObject *, PyObject *args, PyObject *kw)
static std::optional< int > py_imbuf_ftype_from_string(const char *str)
static int py_imbuf_buffer_clear(Py_ImBufBuffer *self)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
static PyObject * py_imbuf_filepath_get(Py_ImBuf *self, void *)
void IMB_freeImBuf(ImBuf *ibuf)
VecBase< int32_t, 2 > int2
static PyObject * py_imbuf_file_type_file_extensions_get(Py_ImBufFileType *self, void *)
static PyModuleDef IMB_types_module_def
PyObject * BPyInit_imbuf()
static PyObject * imbuf_load_from_memory_impl(const char *buffer, const size_t buffer_size, ImBufFlags flags)
static PyObject * imbuf_write_to_buffer_impl(ImBuf *ibuf, PyObject *file)
static PyMethodDef IMB_methods[]
static PyMethodDef Py_ImBufBuffer_methods[]
static PyObject * py_imbuf_buffer_enter(Py_ImBufBuffer *self)
static int py_imbuf_valid_check(Py_ImBuf *self)
static PyObject * M_imbuf_load(PyObject *, PyObject *args, PyObject *kw)
static PyObject * py_imbuf_convert_buffer_type(Py_ImBuf *self, PyObject *args, PyObject *kw)
eImFileTypeCapability IMB_ftype_capability_read(eImbFileType ftype)
static int py_imbuf_filepath_set(Py_ImBuf *self, PyObject *value, void *)
static PyObject * py_imbuf_file_type_id_get(Py_ImBufFileType *self, void *)
static const PyC_StringEnumItems py_imbuf_buffer_mode_items[]
static int py_imbuf_compress_set(Py_ImBuf *self, PyObject *value, void *)
static PyObject * py_imbuf_repr(Py_ImBuf *self)
int PyC_ParseUnicodeAsBytesAndSize(PyObject *o, void *p)
static PyObject * py_imbuf_channels_get(Py_ImBuf *self, void *)
static PyObject * py_imbuf_file_type_repr(Py_ImBufFileType *self)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
static PyObject * py_imbuf_copy(Py_ImBuf *self)
static PyObject * py_imbuf_file_type_capability_write_get(Py_ImBufFileType *self, void *flag_p)
const char * PyC_StringEnum_FindIDFromValue(const PyC_StringEnumItems *items, const int value)
static bool py_imbuf_region_sanitize(const ImBuf *ibuf, rcti *region)
eImFileTypeCapability IMB_ftype_capability_write(eImbFileType ftype)
ImBuf * IMB_allocImBuf(unsigned int x, unsigned int y, ImBufFlags flags)
static PyMethodDef Py_ImBuf_methods[]
static void py_imbuf_dealloc(Py_ImBuf *self)
static PyObject * Py_ImBuf_CreatePyObject(ImBuf *ibuf)
ImBuf * IMB_load_image_from_memory(const unsigned char *mem, size_t size, ImBufFlags flags, const char *descr, const char *filepath=nullptr, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
static std::optional< ImBufFlags > py_imbuf_buffer_type(const ImBuf *ibuf)
eImbFileType IMB_test_image_type_from_memory(const unsigned char *buf, size_t buf_size)
static PyObject * py_imbuf_buffer_type_get(Py_ImBuf *self, void *)
void IMB_byte_from_float(ImBuf *ibuf)
static PyObject * imbuf_write_impl(ImBuf *ibuf, const char *filepath)
static PyModuleDef IMB_module_def
int PyC_ParseOptionalRectI(PyObject *o, void *p)
static const char * py_imbuf_ftype_to_id_with_fallback(const eImbFileType ftype)
int PyC_Module_AddToSysModules(PyObject *sys_modules, PyObject *module)
static int py_imbuf_buffer_traverse(Py_ImBufBuffer *self, visitproc visit, void *arg)
PyObject * PyC_UnicodeFromStdStr(const std::string &str)
static Py_hash_t py_imbuf_hash(Py_ImBuf *self)
int PyC_ParseStringEnum(PyObject *o, void *p)
static PyObject * py_imbuf_resize(Py_ImBuf *self, PyObject *args, PyObject *kw)
static PyGetSetDef Py_ImBuf_getseters[]
PyTypeObject Py_ImBufBuffer_Type
static int py_imbuf_ppm_set(Py_ImBuf *self, PyObject *value, void *)
bool IMB_scale(ImBuf *ibuf, int2 new_size, IMBScaleFilter filter, bool threaded=true)
int PyC_ParseUnicodeAsBytesAndSize_OrNone(PyObject *o, void *p)
static void py_imbuf_buffer_dealloc(Py_ImBufBuffer *self)
ImBuf * BPy_ImBuf_FromPyObject(PyObject *py_imbuf)
static PyObject * py_imbuf_file_type_capability_read_get(Py_ImBufFileType *self, void *flag_p)
void IMB_free_float_pixels(ImBuf *ibuf)
static PyObject * py_imbuf_file_type_get(Py_ImBuf *self, void *)
static PyObject * py_imbuf_write_impl(Py_ImBuf *py_imb, const char *filepath_or_null)
const char * PyC_UnicodeAsBytesAndSize(PyObject *py_str, Py_ssize_t *r_size, PyObject **r_coerce)
ImBuf * IMB_load_image_from_file_descriptor(int file, ImBufFlags flags, const char *filepath=nullptr, ColorManagedColorspaceSettings *colorspace_settings=nullptr)
static PyObject * py_imbuf_ppm_get(Py_ImBuf *self, void *)
static PyObject * py_imbuf_buffer_repr(Py_ImBufBuffer *self)
header-only compatibility defines.
ImbFormatOptions foptions
const uint8_t * byte_data() const
uint8_t * byte_data_for_write()
const float * float_data() const
float * float_data_for_write()
int color_mode_channels_get() const
std::optional< rcti > region
PyObject_HEAD Py_ImBuf * py_ibuf
PyObject_HEAD eImbFileType ftype
PyObject_HEAD ImBuf * ibuf