Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2006-09-16 10:18:41 +0400
committerCampbell Barton <ideasman42@gmail.com>2006-09-16 10:18:41 +0400
commit2b7f09b8ea0747cecbd9b3c0fff542a5eeedeea3 (patch)
tree034a790bb466a4a8f14ccb5a1c59991fab43e470 /source
parent9932322fa8e4ad4ce0859d72f83ef37224c4ec34 (diff)
added Image.SetCurrent(img) and img.has_data so you can see if an image contains pixel info.
Diffstat (limited to 'source')
-rw-r--r--source/blender/python/api2_2x/Image.c40
-rw-r--r--source/blender/python/api2_2x/doc/Image.py11
2 files changed, 47 insertions, 4 deletions
diff --git a/source/blender/python/api2_2x/Image.c b/source/blender/python/api2_2x/Image.c
index cad2b60521c..33f3275f7b8 100644
--- a/source/blender/python/api2_2x/Image.c
+++ b/source/blender/python/api2_2x/Image.c
@@ -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}
@@ -325,6 +331,28 @@ static PyObject *M_Image_GetCurrent( PyObject * self )
}
/*****************************************************************************/
+/* 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 */
/* Description: Receives a string and returns the image object */
@@ -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 )
diff --git a/source/blender/python/api2_2x/doc/Image.py b/source/blender/python/api2_2x/doc/Image.py
index 5ad44243830..9385d7bcc2f 100644
--- a/source/blender/python/api2_2x/doc/Image.py
+++ b/source/blender/python/api2_2x/doc/Image.py
@@ -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).
"""