[Bf-committers] Blender.Image Question
Austin Benesh
doccoaster at msn.com
Sat Feb 19 22:00:25 CET 2005
This is the code I have so far for the getPixelColor function in
Blender.Image, but when I try to write the color to the console just to
test, it gives some non-sense hex code. Could anyone tell me the problem
with my code (I copied much of it from Image_GetDepth)? Much appreciations!
static PyObject *Image_getPixels_g(BPy_Image * self, PyObject *args)
{
PyObject *attr;
Image *image = self->image;
char* p;
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 ) /* if no image data available */
load_image( image, IB_rect, "", 0 ); /* loading it */
if( !image->ibuf ) /* didn't work */
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't load image data in Blender" );
ptr=(x + y * image->ibuf->x) * 4;
attr = Py_BuildValue( "h", image->ibuf->rect[ptr+1] );
p=(char*)image->ibuf->rect[ptr+1];
printf("%p");
if( attr )
return attr;
return EXPP_ReturnPyObjError( PyExc_RuntimeError,
"couldn't get Image.depth attribute" );
};
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.blender.org/pipermail/bf-committers/attachments/20050219/163b98a7/attachment.html
More information about the Bf-committers
mailing list