[Bf-python] Image.New() - At last.

Campbell Barton cbarton at metavr.com
Sat Nov 5 08:19:42 CET 2005


Thanks to (bjmorse?) - it was easy to add Image.New
Works Image.New('Name', width, height) - Cant be fooled with long names 
or bad width/height

- 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;
}



-- 
Campbell J Barton

133 Hope Street
Geelong West, Victoria 3218 Australia

URL:    http://www.metavr.com
e-mail: cbarton at metavr.com
phone: AU (03) 5229 0241



More information about the Bf-python mailing list