// set capture size int ImageViewport_setCaptureSize(PyImage *self, PyObject *value, void *closure) { // check validity of parameter if (value == NULL || !(PyTuple_Check(value) || PyList_Check(value)) || PySequence_Fast_GET_SIZE(value) != 2 || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) { PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); return -1; } // set capture size short size[2] = { short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 0))), short(PyLong_AsLong(PySequence_Fast_GET_ITEM(value, 1))) }; try { // can throw in case of resize and buffer exports getImageViewport(self)->setCaptureSize(size); } catch (Exception & exp) { exp.report(); return -1; } // success return 0; }
// get capture size PyObject *ImageViewport_getCaptureSize (PyImage *self, void *closure) { short *size = getImageViewport(self)->getCaptureSize(); PyObject *ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(size[0])); PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(size[1])); return ret; }
// get position static PyObject *ImageViewport_getPosition (PyImage *self, void *closure) { GLint *pos = getImageViewport(self)->getPosition(); PyObject *ret = PyTuple_New(2); PyTuple_SET_ITEM(ret, 0, PyLong_FromLong(pos[0])); PyTuple_SET_ITEM(ret, 1, PyLong_FromLong(pos[1])); return ret; }
// set whole int ImageViewport_setAlpha (PyImage * self, PyObject * value, void * closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) { PyErr_SetString(PyExc_TypeError, "The value must be a bool"); return -1; } // set alpha if (self->m_image != NULL) getImageViewport(self)->setAlpha(value == Py_True); // success return 0; }
// set capture size int ImageViewport_setCaptureSize (PyImage * self, PyObject * value, void * closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Length(value) != 2 || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) { PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); return -1; } // set capture size short size [] = { short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))), short(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))) }; getImageViewport(self)->setCaptureSize(size); // success return 0; }
// set position static int ImageViewport_setPosition (PyImage * self, PyObject * value, void * closure) { // check validity of parameter if (value == NULL || !PySequence_Check(value) || PySequence_Size(value) != 2 || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 0)) || !PyLong_Check(PySequence_Fast_GET_ITEM(value, 1))) { PyErr_SetString(PyExc_TypeError, "The value must be a sequence of 2 ints"); return -1; } // set position GLint pos [] = { GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 0))), GLint(PyLong_AsSsize_t(PySequence_Fast_GET_ITEM(value, 1))) }; getImageViewport(self)->setPosition(pos); // success return 0; }
// set whole int ImageViewport_setWhole(PyImage *self, PyObject *value, void *closure) { // check parameter, report failure if (value == NULL || !PyBool_Check(value)) { PyErr_SetString(PyExc_TypeError, "The value must be a bool"); return -1; } try { // set whole, can throw in case of resize and buffer exports if (self->m_image != NULL) getImageViewport(self)->setWhole(value == Py_True); } catch (Exception & exp) { exp.report(); return -1; } // success return 0; }
// get capture size PyObject * ImageViewport_getCaptureSize (PyImage * self, void * closure) { return Py_BuildValue("(ii)", getImageViewport(self)->getCaptureSize()[0], getImageViewport(self)->getCaptureSize()[1]); }
// get position static PyObject * ImageViewport_getPosition (PyImage * self, void * closure) { return Py_BuildValue("(ii)", getImageViewport(self)->getPosition()[0], getImageViewport(self)->getPosition()[1]); }
// get alpha PyObject * ImageViewport_getAlpha (PyImage * self, void * closure) { if (self->m_image != NULL && getImageViewport(self)->getAlpha()) Py_RETURN_TRUE; else Py_RETURN_FALSE; }