[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [25772] trunk/blender/source/blender/ makesrna/intern/rna_image.c: patch from Kevin Roy (kiniou), [#20584] get the image size in pixels in Python API

Campbell Barton ideasman42 at gmail.com
Wed Jan 6 11:46:49 CET 2010


Revision: 25772
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=25772
Author:   campbellbarton
Date:     2010-01-06 11:46:49 +0100 (Wed, 06 Jan 2010)

Log Message:
-----------
patch from Kevin Roy (kiniou), [#20584] get the image size in pixels in Python API

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	2010-01-06 10:01:39 UTC (rev 25771)
+++ trunk/blender/source/blender/makesrna/intern/rna_image.c	2010-01-06 10:46:49 UTC (rev 25772)
@@ -153,6 +153,26 @@
 	return 0;
 }
 
+static void rna_Image_size_get(PointerRNA *ptr,int *values)
+{
+	Image *im= (Image*)ptr->data;
+	ImBuf *ibuf;
+	void *lock;
+
+	ibuf = BKE_image_acquire_ibuf(im, NULL , &lock);
+	if (ibuf) {
+		values[0]= ibuf->x;
+		values[1]= ibuf->y;
+	}
+    else {
+		values[0]= 0;
+		values[1]= 0;
+	}
+
+	BKE_image_release_ibuf(im, lock);
+}
+
+
 static int rna_Image_depth_get(PointerRNA *ptr)
 {
 	Image *im= (Image*)ptr->data;
@@ -401,6 +421,10 @@
 	RNA_def_property_ui_text(prop, "Depth", "Image bit depth.");
 	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
 
+	prop= RNA_def_int_vector(srna, "size" , 2 , NULL , 0, 0, "Size" , "Width and height in pixels, zero when image data cant be loaded." , 0 , 0);
+	RNA_def_property_int_funcs(prop, "rna_Image_size_get" , NULL, NULL);
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+
 	RNA_api_image(srna);
 }
 





More information about the Bf-blender-cvs mailing list