[Bf-blender-cvs] [aba6fc8208d] master: ImBuf Py API: implement resize method argument

Campbell Barton noreply at git.blender.org
Mon Sep 30 21:22:21 CEST 2019


Commit: aba6fc8208d659b3bf4ff2b7353ec195d6d34904
Author: Campbell Barton
Date:   Tue Oct 1 04:12:12 2019 +1000
Branches: master
https://developer.blender.org/rBaba6fc8208d659b3bf4ff2b7353ec195d6d34904

ImBuf Py API: implement resize method argument

===================================================================

M	source/blender/python/generic/imbuf_py_api.c

===================================================================

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;
 }



More information about the Bf-blender-cvs mailing list