no need to use a temporary in tuple translation, and clamp the result.
2008-01-26 Manish Singh <yosh@gimp.org> * plug-ins/pygimp/pygimp-colors.c (pygimp_rgb_from_pyobject): no need to use a temporary in tuple translation, and clamp the result. * plug-ins/pygimp/gimpmodule.c (pygimp_set_background, pygimp_set_foreground): restore support for passing in 3 args for color components, for backward compatibility. svn path=/trunk/; revision=24716
This commit is contained in:

committed by
Manish Singh

parent
2ca4dcf882
commit
feff2c6b6d
11
ChangeLog
11
ChangeLog
@ -1,4 +1,13 @@
|
|||||||
2008-01-26 Joao S. O. Bueno <gwidion@mpc.com.br>
|
2008-01-26 Manish Singh <yosh@gimp.org>
|
||||||
|
|
||||||
|
* plug-ins/pygimp/pygimp-colors.c (pygimp_rgb_from_pyobject): no
|
||||||
|
need to use a temporary in tuple translation, and clamp the result.
|
||||||
|
|
||||||
|
* plug-ins/pygimp/gimpmodule.c (pygimp_set_background,
|
||||||
|
pygimp_set_foreground): restore support for passing in 3 args for
|
||||||
|
color components, for backward compatibility.
|
||||||
|
|
||||||
|
2008-01-26 Joao S. O. Bueno <gwidion@mpc.com.br>
|
||||||
|
|
||||||
* plug-ins/pygimp/pygimp-colors.c (pygimp_rgb_from_pyobject): fix
|
* plug-ins/pygimp/pygimp-colors.c (pygimp_rgb_from_pyobject): fix
|
||||||
subsequent error (calculated parameters where not used)
|
subsequent error (calculated parameters where not used)
|
||||||
|
@ -837,30 +837,12 @@ pygimp_set_background(PyObject *self, PyObject *args)
|
|||||||
GimpRGB rgb;
|
GimpRGB rgb;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, "O:set_background", &color)) {
|
if (PyArg_ParseTuple(args, "O:set_background", &color)) {
|
||||||
if (! pygimp_rgb_from_pyobject (color, &rgb)) {
|
if (!pygimp_rgb_from_pyobject(color, &rgb))
|
||||||
PyErr_Clear();
|
|
||||||
PyArg_ParseTuple(args, "O!:set_background", PyGimpRGB_Type, &color);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (!PyArg_ParseTuple(args, "(iii):set_background", &r, &g, &b)) {
|
if (!pygimp_rgb_from_pyobject(args, &rgb))
|
||||||
PyErr_Clear();
|
return NULL;
|
||||||
if (!PyArg_ParseTuple(args, "iii:set_background", &r, &g, &b)) {
|
|
||||||
PyErr_Clear();
|
|
||||||
PyArg_ParseTuple(args, "O!:set_background",
|
|
||||||
PyGimpRGB_Type, &color);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r = CLAMP(r, 0, 255);
|
|
||||||
g = CLAMP(g, 0, 255);
|
|
||||||
b = CLAMP(b, 0, 255);
|
|
||||||
|
|
||||||
gimp_rgba_set_uchar(&rgb, r, g, b, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_context_set_background(&rgb);
|
gimp_context_set_background(&rgb);
|
||||||
@ -876,30 +858,12 @@ pygimp_set_foreground(PyObject *self, PyObject *args)
|
|||||||
GimpRGB rgb;
|
GimpRGB rgb;
|
||||||
|
|
||||||
if (PyArg_ParseTuple(args, "O:set_foreground", &color)) {
|
if (PyArg_ParseTuple(args, "O:set_foreground", &color)) {
|
||||||
if (! pygimp_rgb_from_pyobject (color, &rgb)) {
|
if (!pygimp_rgb_from_pyobject(color, &rgb))
|
||||||
PyErr_Clear();
|
|
||||||
PyArg_ParseTuple(args, "O!:set_foreground", PyGimpRGB_Type, &color);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
int r, g, b;
|
|
||||||
|
|
||||||
PyErr_Clear();
|
PyErr_Clear();
|
||||||
if (!PyArg_ParseTuple(args, "(iii):set_foreground", &r, &g, &b)) {
|
if (!pygimp_rgb_from_pyobject(args, &rgb))
|
||||||
PyErr_Clear();
|
return NULL;
|
||||||
if (!PyArg_ParseTuple(args, "iii:set_foreground", &r, &g, &b)) {
|
|
||||||
PyErr_Clear();
|
|
||||||
PyArg_ParseTuple(args, "O!:set_foreground",
|
|
||||||
PyGimpRGB_Type, &color);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
r = CLAMP(r, 0, 255);
|
|
||||||
g = CLAMP(g, 0, 255);
|
|
||||||
b = CLAMP(b, 0, 255);
|
|
||||||
|
|
||||||
gimp_rgba_set_uchar(&rgb, r, g, b, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gimp_context_set_foreground(&rgb);
|
gimp_context_set_foreground(&rgb);
|
||||||
|
@ -2372,7 +2372,6 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
} else if (PySequence_Check(object)) {
|
} else if (PySequence_Check(object)) {
|
||||||
GimpRGB rgb;
|
|
||||||
PyObject *r, *g, *b, *a = NULL;
|
PyObject *r, *g, *b, *a = NULL;
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(object, "OOO|O", &r, &g, &b, &a))
|
if (!PyArg_ParseTuple(object, "OOO|O", &r, &g, &b, &a))
|
||||||
@ -2380,9 +2379,9 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color)
|
|||||||
|
|
||||||
#define SET_MEMBER(m) G_STMT_START { \
|
#define SET_MEMBER(m) G_STMT_START { \
|
||||||
if (PyInt_Check(m)) \
|
if (PyInt_Check(m)) \
|
||||||
rgb.m = (double) PyInt_AS_LONG(m) / 255.0; \
|
color->m = (double) PyInt_AS_LONG(m) / 255.0; \
|
||||||
else if (PyFloat_Check(m)) \
|
else if (PyFloat_Check(m)) \
|
||||||
rgb.m = PyFloat_AS_DOUBLE(m); \
|
color->m = PyFloat_AS_DOUBLE(m); \
|
||||||
else { \
|
else { \
|
||||||
PyErr_SetString(PyExc_TypeError, \
|
PyErr_SetString(PyExc_TypeError, \
|
||||||
#m " must be an int or a float"); \
|
#m " must be an int or a float"); \
|
||||||
@ -2397,11 +2396,9 @@ pygimp_rgb_from_pyobject(PyObject *object, GimpRGB *color)
|
|||||||
if (a)
|
if (a)
|
||||||
SET_MEMBER(a);
|
SET_MEMBER(a);
|
||||||
else
|
else
|
||||||
rgb.a = 1.0;
|
color->a = 1.0;
|
||||||
color->r = rgb.r;
|
|
||||||
color->g = rgb.g;
|
gimp_rgb_clamp(color);
|
||||||
color->b = rgb.b;
|
|
||||||
color->a = rgb.a;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user