Commit 7414d0bc authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann

plug-ins/pygimp/pygimp-drawable.c added optional interpolation parameters

2008-09-24  Sven Neumann  <sven@gimp.org>

	* plug-ins/pygimp/pygimp-drawable.c
	* plug-ins/pygimp/pygimp-image.c: added optional interpolation
	parameters to the image.scale() and layer.scale() methods.


svn path=/trunk/; revision=27042
parent 8fb79f14
2008-09-24 Sven Neumann <sven@gimp.org>
* plug-ins/pygimp/pygimp-drawable.c
* plug-ins/pygimp/pygimp-image.c: added optional interpolation
parameters to the image.scale() and layer.scale() methods.
2008-09-24 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpcontrollereditor.c
......
......@@ -1388,20 +1388,33 @@ lay_resize_to_image_size(PyGimpLayer *self)
static PyObject *
lay_scale(PyGimpLayer *self, PyObject *args, PyObject *kwargs)
{
unsigned int new_w, new_h;
int new_width, new_height;
int interpolation = -1;
gboolean local_origin = FALSE;
static char *kwlist[] = { "width", "height", "local_origin", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:scale", kwlist,
&new_w, &new_h, &local_origin))
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|ii:scale", kwlist,
&new_width, &new_height,
&local_origin, &interpolation))
return NULL;
if (!gimp_layer_scale(self->ID, new_w, new_h, local_origin)) {
PyErr_Format(pygimp_error,
"could not scale layer (ID %d) to size %dx%d",
self->ID, new_w, new_h);
return NULL;
if (interpolation != -1) {
if (!gimp_layer_scale_full(self->ID,
new_width, new_height,
local_origin, interpolation)) {
PyErr_Format(pygimp_error,
"could not scale layer (ID %d) to size %dx%d",
self->ID, new_width, new_height);
return NULL;
}
} else {
if (!gimp_layer_scale(self->ID, new_width, new_height, local_origin)) {
PyErr_Format(pygimp_error,
"could not scale layer (ID %d) to size %dx%d",
self->ID, new_width, new_height);
return NULL;
}
}
Py_INCREF(Py_None);
......
......@@ -445,17 +445,27 @@ static PyObject *
img_scale(PyGimpImage *self, PyObject *args, PyObject *kwargs)
{
int new_width, new_height;
int interpolation = -1;
static char *kwlist[] = { "width", "height", NULL };
static char *kwlist[] = { "width", "height", "interpolation", NULL };
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii:scale", kwlist,
&new_width, &new_height))
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ii|i:scale", kwlist,
&new_width, &new_height, &interpolation))
return NULL;
if (!gimp_image_scale(self->ID, new_width, new_height)) {
PyErr_Format(pygimp_error, "could not scale image (ID %d) to %dx%d",
self->ID, new_width, new_height);
return NULL;
if (interpolation != -1) {
if (!gimp_image_scale_full(self->ID,
new_width, new_height, interpolation)) {
PyErr_Format(pygimp_error, "could not scale image (ID %d) to %dx%d",
self->ID, new_width, new_height);
return NULL;
}
} else {
if (!gimp_image_scale(self->ID, new_width, new_height)) {
PyErr_Format(pygimp_error, "could not scale image (ID %d) to %dx%d",
self->ID, new_width, new_height);
return NULL;
}
}
Py_INCREF(Py_None);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment