Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2008-05-25 20:39:57 +0400
committerCampbell Barton <ideasman42@gmail.com>2008-05-25 20:39:57 +0400
commitb306aaccb950c11afea79b3be7289def7853ea62 (patch)
tree125e4ca4d2a47aa2f13e0a7cf9e0eb4fa24542b6 /source/blender/python
parent20b4bf4abaff8723421fb2fed96eff90e9ed1a00 (diff)
patch [#11491] Fix for bug 11362: Blender.Draw.Image() method does not clip properly
fixing [#11362] Blender.Draw.Image() method does not clip properly also return silently on zero zoomlevel rather then raising an error, only raise an error on negative values.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/api2_2x/Draw.c25
1 files changed, 12 insertions, 13 deletions
diff --git a/source/blender/python/api2_2x/Draw.c b/source/blender/python/api2_2x/Draw.c
index cd7ec781b2b..3d4546613be 100644
--- a/source/blender/python/api2_2x/Draw.c
+++ b/source/blender/python/api2_2x/Draw.c
@@ -2063,22 +2063,22 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
/*GLfloat scissorBox[4];*/
/* parse the arguments passed-in from Python */
- if( !PyArg_ParseTuple( args, "Off|ffiiii", &pyObjImage,
+ if( !PyArg_ParseTuple( args, "O!ff|ffiiii", &Image_Type, &pyObjImage,
&originX, &originY, &zoomX, &zoomY,
&clipX, &clipY, &clipW, &clipH ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected a Blender.Image and 2 floats, and " \
"optionally 2 floats and 4 ints as arguments" );
- /* check that the first PyObject is actually a Blender.Image */
- if( !BPy_Image_Check( pyObjImage ) )
- return EXPP_ReturnPyObjError( PyExc_TypeError,
- "expected a Blender.Image and 2 floats, and " \
- "optionally 2 floats and 4 ints as arguments" );
/* check that the zoom factors are valid */
- if( ( zoomX <= 0.0 ) || ( zoomY <= 0.0 ) )
+ if( ( zoomX < 0.0 ) || ( zoomY < 0.0 ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
- "invalid zoom factors - they must be >= 0.0" );
-
+ "invalid zoom factors - they must be > 0.0" );
+ if ((zoomX == 0.0 ) || ( zoomY == 0.0 )) {
+ /* sometimes python doubles can be converted from small values to a zero float, in this case just dont draw */
+ Py_RETURN_NONE;
+ }
+
+
/* fetch a C Image pointer from the passed-in Python object */
py_img = ( BPy_Image * ) pyObjImage;
image = py_img->image;
@@ -2101,9 +2101,9 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
* the image as they can. */
clipX = EXPP_ClampInt( clipX, 0, ibuf->x );
clipY = EXPP_ClampInt( clipY, 0, ibuf->y );
- if( ( clipW < 0 ) || ( clipW > ( ibuf->x - clipW ) ) )
+ if( ( clipW < 0 ) || ( clipX+clipW > ibuf->x ) )
clipW = ibuf->x - clipX;
- if( ( clipH < 0 ) || ( clipH > ( ibuf->y - clipH ) ) )
+ if( ( clipH < 0 ) || ( clipY+clipH > ibuf->y ) )
clipH = ibuf->y - clipY;
/* -- we are "Go" to Draw! -- */
@@ -2165,8 +2165,7 @@ static PyObject *Method_Image( PyObject * self, PyObject * args )
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}