[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14966] trunk/blender/source/blender/ python/api2_2x/Draw.c: patch [#11491] Fix for bug 11362: Blender.Draw. Image() method does not clip properly
Campbell Barton
ideasman42 at gmail.com
Sun May 25 18:39:59 CEST 2008
Revision: 14966
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14966
Author: campbellbarton
Date: 2008-05-25 18:39:57 +0200 (Sun, 25 May 2008)
Log Message:
-----------
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.
Modified Paths:
--------------
trunk/blender/source/blender/python/api2_2x/Draw.c
Modified: trunk/blender/source/blender/python/api2_2x/Draw.c
===================================================================
--- trunk/blender/source/blender/python/api2_2x/Draw.c 2008-05-25 16:07:32 UTC (rev 14965)
+++ trunk/blender/source/blender/python/api2_2x/Draw.c 2008-05-25 16:39:57 UTC (rev 14966)
@@ -2063,22 +2063,22 @@
/*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 @@
* 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 @@
glPixelStorei( GL_UNPACK_SKIP_PIXELS, 0 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0 );
- Py_INCREF( Py_None );
- return Py_None;
+ Py_RETURN_NONE;
}
More information about the Bf-blender-cvs
mailing list