static int pf_set_bg_color(PyGimpPixelFetcher *self, PyObject *value, void *closure) { if (value == NULL) { PyErr_SetString(PyExc_TypeError, "cannot delete bg_color"); return -1; } if (!pygimp_rgb_from_pyobject(value, &self->bg_color)) return -1; gimp_pixel_fetcher_set_bg_color(self->pf, &self->bg_color); return 0; }
static PyObject * pygimp_bilinear_color(PyObject *self, PyObject *args, PyObject *kwargs, gboolean with_alpha) { gdouble x, y; GimpRGB values[4]; GimpRGB rgb; PyObject *py_values, *v; int i, success; static char *kwlist[] = { "x", "y", "values", NULL }; if (!PyArg_ParseTupleAndKeywords(args, kwargs, with_alpha ? "ddO:bilinear_rgba" : "ddO:bilinear_rgb", kwlist, &x, &y, &py_values)) return NULL; if (!PySequence_Check(py_values) || PySequence_Size(py_values) != 4) { PyErr_SetString(PyExc_TypeError, "values is not a sequence of 4 items"); return NULL; } for (i = 0; i < 4; i++) { v = PySequence_GetItem(py_values, i); success = pygimp_rgb_from_pyobject(v, &values[i]); Py_DECREF(v); if (!success) { PyErr_Format(PyExc_TypeError, "values[%d] is not a GimpRGB", i); return NULL; } } if (with_alpha) rgb = gimp_bilinear_rgba(x, y, values); else rgb = gimp_bilinear_rgb(x, y, values); return pygimp_rgb_new(&rgb); }