gimp r24716 - in trunk: . plug-ins/pygimp
- From: yosh svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r24716 - in trunk: . plug-ins/pygimp
- Date: Sun, 27 Jan 2008 05:09:29 +0000 (GMT)
Author: yosh
Date: Sun Jan 27 05:09:28 2008
New Revision: 24716
URL: http://svn.gnome.org/viewvc/gimp?rev=24716&view=rev
Log:
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.
Modified:
trunk/ChangeLog
trunk/plug-ins/pygimp/gimpmodule.c
trunk/plug-ins/pygimp/pygimp-colors.c
Modified: trunk/plug-ins/pygimp/gimpmodule.c
==============================================================================
--- trunk/plug-ins/pygimp/gimpmodule.c (original)
+++ trunk/plug-ins/pygimp/gimpmodule.c Sun Jan 27 05:09:28 2008
@@ -837,30 +837,12 @@
GimpRGB rgb;
if (PyArg_ParseTuple(args, "O:set_background", &color)) {
- if (! pygimp_rgb_from_pyobject (color, &rgb)) {
- PyErr_Clear();
- PyArg_ParseTuple(args, "O!:set_background", PyGimpRGB_Type, &color);
+ if (!pygimp_rgb_from_pyobject(color, &rgb))
return NULL;
- }
} else {
- int r, g, b;
-
PyErr_Clear();
- if (!PyArg_ParseTuple(args, "(iii):set_background", &r, &g, &b)) {
- PyErr_Clear();
- 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);
+ if (!pygimp_rgb_from_pyobject(args, &rgb))
+ return NULL;
}
gimp_context_set_background(&rgb);
@@ -876,30 +858,12 @@
GimpRGB rgb;
if (PyArg_ParseTuple(args, "O:set_foreground", &color)) {
- if (! pygimp_rgb_from_pyobject (color, &rgb)) {
- PyErr_Clear();
- PyArg_ParseTuple(args, "O!:set_foreground", PyGimpRGB_Type, &color);
+ if (!pygimp_rgb_from_pyobject(color, &rgb))
return NULL;
- }
} else {
- int r, g, b;
-
PyErr_Clear();
- if (!PyArg_ParseTuple(args, "(iii):set_foreground", &r, &g, &b)) {
- PyErr_Clear();
- 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);
+ if (!pygimp_rgb_from_pyobject(args, &rgb))
+ return NULL;
}
gimp_context_set_foreground(&rgb);
Modified: trunk/plug-ins/pygimp/pygimp-colors.c
==============================================================================
--- trunk/plug-ins/pygimp/pygimp-colors.c (original)
+++ trunk/plug-ins/pygimp/pygimp-colors.c Sun Jan 27 05:09:28 2008
@@ -2372,7 +2372,6 @@
return 0;
}
} else if (PySequence_Check(object)) {
- GimpRGB rgb;
PyObject *r, *g, *b, *a = NULL;
if (!PyArg_ParseTuple(object, "OOO|O", &r, &g, &b, &a))
@@ -2380,9 +2379,9 @@
#define SET_MEMBER(m) G_STMT_START { \
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)) \
- rgb.m = PyFloat_AS_DOUBLE(m); \
+ color->m = PyFloat_AS_DOUBLE(m); \
else { \
PyErr_SetString(PyExc_TypeError, \
#m " must be an int or a float"); \
@@ -2397,11 +2396,9 @@
if (a)
SET_MEMBER(a);
else
- rgb.a = 1.0;
- color->r = rgb.r;
- color->g = rgb.g;
- color->b = rgb.b;
- color->a = rgb.a;
+ color->a = 1.0;
+
+ gimp_rgb_clamp(color);
return 1;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]