[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [47050] trunk/blender/source/blender/ makesrna/intern/rna_image.c: Add frame_duration read-only member to Image RNA struct, returns movie' s length in frames (or 1 for still images).

Bastien Montagne montagne29 at wanadoo.fr
Sat May 26 16:53:33 CEST 2012


Revision: 47050
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=47050
Author:   mont29
Date:     2012-05-26 14:53:33 +0000 (Sat, 26 May 2012)
Log Message:
-----------
Add frame_duration read-only member to Image RNA struct, returns movie's length in frames (or 1 for still images).

Modified Paths:
--------------
    trunk/blender/source/blender/makesrna/intern/rna_image.c

Modified: trunk/blender/source/blender/makesrna/intern/rna_image.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_image.c	2012-05-26 14:31:34 UTC (rev 47049)
+++ trunk/blender/source/blender/makesrna/intern/rna_image.c	2012-05-26 14:53:33 UTC (rev 47050)
@@ -53,6 +53,7 @@
 
 #ifdef RNA_RUNTIME
 
+#include "IMB_imbuf.h"
 #include "IMB_imbuf_types.h"
 
 static void rna_Image_animated_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -287,6 +288,15 @@
 	return planes;
 }
 
+static int rna_Image_frame_duration_get(PointerRNA *ptr)
+{
+	Image *im = (Image *)ptr->data;
+
+	if (im->anim)
+		return IMB_anim_get_duration(im->anim, IMB_TC_RECORD_RUN);
+	return 1;
+}
+
 static int rna_Image_pixels_get_length(PointerRNA *ptr, int length[RNA_MAX_ARRAY_DIMENSION])
 {
 	Image *ima = ptr->id.data;
@@ -629,6 +639,11 @@
 	prop = RNA_def_float_vector(srna, "resolution", 2, NULL, 0, 0, "Resolution", "X/Y pixels per meter", 0, 0);
 	RNA_def_property_float_funcs(prop, "rna_Image_resolution_get", "rna_Image_resolution_set", NULL);
 
+	prop = RNA_def_property(srna, "frame_duration", PROP_INT, PROP_UNSIGNED);
+	RNA_def_property_int_funcs(prop, "rna_Image_frame_duration_get", NULL, NULL);
+	RNA_def_property_ui_text(prop, "Duration", "Duration (in frames) of the image (1 when not a video/sequence)");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
 	prop = RNA_def_property(srna, "pixels", PROP_FLOAT, PROP_NONE);
 	RNA_def_property_flag(prop, PROP_DYNAMIC);
 	RNA_def_property_multi_array(prop, 1, NULL);




More information about the Bf-blender-cvs mailing list