[Bf-python] Image.New()- commit?

Campbell Barton cbarton at metavr.com
Tue Dec 13 11:43:41 CET 2005


Hey Guys
Have a working Image.New function that I posted a while back. I tested 
and couldent crash it- accounted for stupig input etc.
Was wondering if I could commit it to bf-blender-

Post from a while back, no response.
- All the New() related stuff is commented. Heres the main function.

/*****************************************************************************/ 

/* Function:    M_Image_New     */
/* Python equivalent:        Blender.Image.New    */
/*****************************************************************************/ 

static PyObject *M_Image_New( PyObject * self, PyObject * args,    
PyObject * keywords )
{
   int width, height;
   char *name;
   Image *img_ptr;
   BPy_Image *img;
     if( !PyArg_ParseTuple( args, "sii", &name, &width, &height ) )
       return ( EXPP_ReturnPyObjError( PyExc_TypeError,
                       "expected 1 string and 2 ints" ) );
   if (width > 5000 || height > 5000 || width < 1 || height < 1)
       return ( EXPP_ReturnPyObjError( PyExc_TypeError,
                       "Image width and height must be between 1 and 
5000" ) );
     img_ptr = new_image(width, height, name);
   image_changed(img_ptr, 0);
     img = ( BPy_Image * ) PyObject_NEW( BPy_Image, &Image_Type );
   img->image = img_ptr;
   return ( PyObject * ) img;
}




- Cam



More information about the Bf-python mailing list