From aba6fc8208d659b3bf4ff2b7353ec195d6d34904 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 1 Oct 2019 04:12:12 +1000 Subject: ImBuf Py API: implement resize method argument --- source/blender/python/generic/imbuf_py_api.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'source/blender/python') 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; } -- cgit v1.2.3