diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-09-30 21:12:12 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-09-30 22:18:30 +0300 |
commit | aba6fc8208d659b3bf4ff2b7353ec195d6d34904 (patch) | |
tree | 21fa0ee1a12285cb66f6292891c7cfe9b58175bd /source/blender/python | |
parent | 07feb6e81441b084775e7cb7a042fc19c8c126d4 (diff) |
ImBuf Py API: implement resize method argument
Diffstat (limited to 'source/blender/python')
-rw-r--r-- | source/blender/python/generic/imbuf_py_api.c | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/source/blender/python/generic/imbuf_py_api.c b/source/blender/python/generic/imbuf_py_api.c index 593145476ad..ff5e4769f19 100644 --- a/source/blender/python/generic/imbuf_py_api.c +++ b/source/blender/python/generic/imbuf_py_api.c @@ -88,21 +88,37 @@ PyDoc_STRVAR(py_imbuf_resize_doc, "\n" " :arg size: New size.\n" " :type size: pair of ints\n" - " :arg method: Method of resizing (TODO)\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) { PY_IMBUF_CHECK_OBJ(self); uint size[2]; - char *method = NULL; + + enum { FAST, BILINEAR }; + const struct PyC_StringEnumItems method_items[] = { + {FAST, "FAST"}, + {BILINEAR, "BILINEAR"}, + {0, NULL}, + }; + struct PyC_StringEnum method = {method_items, FAST}; static const char *_keywords[] = {"size", "method", NULL}; - static _PyArg_Parser _parser = {"(II)|s:resize", _keywords, 0}; - if (!_PyArg_ParseTupleAndKeywordsFast(args, kw, &_parser, &size[0], &size[1], &method)) { + static _PyArg_Parser _parser = {"(II)|O&:resize", _keywords, 0}; + if (!_PyArg_ParseTupleAndKeywordsFast( + args, kw, &_parser, &size[0], &size[1], PyC_ParseStringEnum, &method)) { return NULL; } - IMB_scaleImBuf(self->ibuf, UNPACK2(size)); + 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); + } Py_RETURN_NONE; } |