[Bf-committers] New Python Function - Patch
Austin Benesh
doccoaster at msn.com
Tue Feb 22 02:50:46 CET 2005
Skipped content of type multipart/alternative-------------- next part --------------
Index: sourc/blender/python/api2_2x/Image.c
===========================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/python/api2_2x/Image.c,v
retrieving 1.94
diff -u -p -r1.94Image.c
+++source/blender/python/api2_2x/Image.c 21 Feb 2005 18:39:20 -0700
@@ +218,1@@
static PyObject *Image_getPixelColor(BPy_Image * self, PyObject *args)
{
PyObject *attr;
Image *image=self->image;
char* pixel;
int ptr;
int x=0;
int y=0;
if( !PyArg_ParseTuple( args, "ii", &x, &y ) )
return EXPP_ReturnPyObjError( PyExc_TypeError,
"expected 2 integers" );
if( !image->ibuf||!image->ibuf->rect ) /* if no image data available */
load_image( image, IB_rect, "", 0 ); /* loading it */
if( !image->ibuf||!image->ibuf->rect ) /* didn't work */
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't load image data in Blender" );
if(x>image->ibuf->x||y>image->ibuf->y||image->ibuf->xorig>x||image->ibuf->yorig>y)
return EXPP_ReturnPyObjError( PyExc_RuntimeError, "x or y is out of range");
ptr=(x + y* image->ibuf->x)*4;
pixel=(char*)image->ibuf->rect;
attr = Py_BuildValue( "[f,f,f,f]", ((float)pixel[ptr])/255,((float)pixel[ptr+1])/255,((float)pixel[ptr+2])/255,((float)pixel[ptr+3]/255) );
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get pixel colors" );
};
@@++292,1@@
static PyObject *Image_getPixelColor(BPy_Image * self, PyObject *args); /* by Austin Benesh */
@@++299,4@@
{"getPixelColor", ( PyCFunction ) Image_getPixelColor, METH_VARARGS,
"(int) X,Y"},
More information about the Bf-committers
mailing list