On Sun, 2011-04-03 at 16:17 +0000, Brecht Van Lommel wrote:
> Revision: 35976
>           
> http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=35976
> Author:   blendix
> Date:     2011-04-03 16:17:39 +0000 (Sun, 03 Apr 2011)
> Log Message:
> -----------
> Image pixel access, through Image.pixels as floating point values.

This gets unusably slow on larger images. And by "large" I mean that 256
x 256 has massive delays. The problem seems to be in the
multidimensional array reads. Writing is ok, but reads are very slow.

Just simple console testing on a 128 x 128 image takes about 10 seconds:

img=bpy.data.images.new('test', width=128, height=128)
pix = list(img.pixels)
img.pixels = pix

I've hacked a pixels_raw property (probably wrongly as I'm not a C
coder :p ) that's one long list of floats and it works much much faster.
I've attached the diff.

img=bpy.data.images.new('test', width=128, height=128)
pix = list(img.pixels_raw)
img.pixels_raw = pix

is under a second. Is it possible to get the (corrected if needed) raw
version added or replace the original with it?


=== modified file 'source/blender/makesrna/intern/rna_image.c'
--- source/blender/makesrna/intern/rna_image.c	2011-04-03 16:17:39 +0000
+++ source/blender/makesrna/intern/rna_image.c	2011-04-04 15:46:54 +0000
@@ -566,6 +566,14 @@
 	RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
 	RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
 
+	prop= RNA_def_property(srna, "pixels_raw", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_array(prop, 0);
+	RNA_def_property_flag(prop, PROP_DYNAMIC);
+	RNA_def_property_ui_text(prop, "Raw Pixels", "Image pixels in floating point values");
+	RNA_def_property_dynamic_array_funcs(prop, "rna_Image_pixels_get_length");
+	RNA_def_property_float_funcs(prop, "rna_Image_pixels_get", "rna_Image_pixels_set", NULL);
+
+
 	RNA_api_image(srna);
 }
 

_______________________________________________
Bf-committers mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-committers

Reply via email to