added Image.SetCurrent(img) and img.has_data so you can see if an image contains pixel info.
This commit is contained in:
@@ -70,6 +70,7 @@ current image frame, some images change frame if they are a sequence */
|
||||
static PyObject *M_Image_New( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Image_Get( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Image_GetCurrent( PyObject * self );
|
||||
static PyObject *M_Image_SetCurrent( PyObject * self, PyObject * args );
|
||||
static PyObject *M_Image_Load( PyObject * self, PyObject * args );
|
||||
|
||||
|
||||
@@ -195,6 +196,10 @@ static char M_Image_GetCurrent_doc[] =
|
||||
"() - return the current image, from last active the uv/image view, \
|
||||
returns None no image is in the view.\n";
|
||||
|
||||
static char M_Image_SetCurrent_doc[] =
|
||||
"(image) - set the image to be the current, from last active the uv/image view, \
|
||||
returns False if no image could be set.";
|
||||
|
||||
static char M_Image_Load_doc[] =
|
||||
"(filename) - return image from file filename as Image Object, \
|
||||
returns None if not found.\n";
|
||||
@@ -206,6 +211,7 @@ struct PyMethodDef M_Image_methods[] = {
|
||||
{"New", M_Image_New, METH_VARARGS, M_Image_New_doc},
|
||||
{"Get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
|
||||
{"GetCurrent", ( PyCFunction ) M_Image_GetCurrent, METH_NOARGS, M_Image_GetCurrent_doc},
|
||||
{"SetCurrent", ( PyCFunction ) M_Image_SetCurrent, METH_VARARGS, M_Image_SetCurrent_doc},
|
||||
{"get", M_Image_Get, METH_VARARGS, M_Image_Get_doc},
|
||||
{"Load", M_Image_Load, METH_VARARGS, M_Image_Load_doc},
|
||||
{NULL, NULL, 0, NULL}
|
||||
@@ -324,6 +330,28 @@ static PyObject *M_Image_GetCurrent( PyObject * self )
|
||||
return Image_CreatePyObject( G.sima->image );
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Image_SetCurrent*/
|
||||
/* Python equivalent: Blender.Image.SetCurrent */
|
||||
/* Description: Sets the active current (G.sima) */
|
||||
/* This will be the image last under the mouse cursor */
|
||||
/* None if there is no Image. */
|
||||
/*****************************************************************************/
|
||||
static PyObject *M_Image_SetCurrent( PyObject * self, PyObject * args )
|
||||
{
|
||||
BPy_Image *image;
|
||||
|
||||
if (!G.sima)
|
||||
Py_RETURN_FALSE;
|
||||
|
||||
if( !PyArg_ParseTuple( args, "O!", &Image_Type, &image) )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_TypeError,
|
||||
"expected an image argument" ) );
|
||||
|
||||
G.sima->image= image->image;
|
||||
Py_RETURN_TRUE;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Function: M_Image_Load */
|
||||
/* Python equivalent: Blender.Image.Load */
|
||||
@@ -351,7 +379,7 @@ static PyObject *M_Image_Load( PyObject * self, PyObject * args )
|
||||
return ( EXPP_ReturnPyObjError( PyExc_IOError,
|
||||
"couldn't load image" ) );
|
||||
|
||||
//reload the image buffers
|
||||
/*reload the image buffers/*
|
||||
free_image_buffers(img_ptr);
|
||||
img_ptr->ibuf = IMB_loadiffname(img_ptr->name , 0);
|
||||
|
||||
@@ -1155,16 +1183,20 @@ static PyObject *Image_getAttr( BPy_Image * self, char *name )
|
||||
attr = EXPP_incr_ret_True();
|
||||
else
|
||||
attr = EXPP_incr_ret_False();
|
||||
|
||||
} else if( strcmp( name, "has_data" ) == 0 ) {
|
||||
if (self->image->ibuf)
|
||||
attr = EXPP_incr_ret_True();
|
||||
else
|
||||
attr = EXPP_incr_ret_False();
|
||||
} else if( strcmp( name, "bindcode" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->bindcode );
|
||||
else if( strcmp( name, "users" ) == 0 )
|
||||
attr = PyInt_FromLong( self->image->id.us );
|
||||
else if( strcmp( name, "__members__" ) == 0 )
|
||||
attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s]",
|
||||
attr = Py_BuildValue( "[s,s,s,s,s,s,s,s,s,s,s,s]",
|
||||
"name", "filename", "size", "depth",
|
||||
"xrep", "yrep", "start", "end",
|
||||
"speed", "packed",
|
||||
"speed", "packed", "has_data"
|
||||
"bindcode", "users" );
|
||||
|
||||
if( !attr )
|
||||
|
||||
@@ -65,6 +65,16 @@ def GetCurrent ():
|
||||
@return: The Current Blender Image, If there is no current image it returns None.
|
||||
"""
|
||||
|
||||
def SetCurrent (image):
|
||||
"""
|
||||
Set the currently displayed Image from Blenders UV/Image window.
|
||||
When multiple images are displayed, the last active UV/Image windows image is used.
|
||||
@type image: Blender Image
|
||||
@param image: The image to display in the image view.
|
||||
@rtype: bool
|
||||
@return: True if the current image could be set, if no window was available, it will be set to False.
|
||||
"""
|
||||
|
||||
class Image:
|
||||
"""
|
||||
The Image object
|
||||
@@ -83,6 +93,7 @@ class Image:
|
||||
@ivar end: Texture's animation end frame [0, 128].
|
||||
@ivar speed: Texture's animation speed [1, 100].
|
||||
@ivar packed: Boolean, True when the Texture is packed (readonly).
|
||||
@ivar has_data: Boolean, True when the image has pixel data (readonly).
|
||||
@ivar bindcode: Texture's bind code (readonly).
|
||||
"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user