[Bf-committers] Question about Image RNA/DNA + Patch

Kevin ROY kiniou at gmail.com
Tue Jan 5 14:03:30 CET 2010


Hi,

I'm looking for some help or good directions to make the size in pixels
from an image available through RNA. For the use case, I need these 2
props in a script that export meshes for NintendoDS CallList and more
particularly when it exports UV coordinates ( e.g. [0.0,1.0[ become
[0,128[ according to a 128x128 texture) .

In the 2.4x Python API, we can get the size from Image.Image.getSize()
but i didn't found any clue on how to do it in 2.5 API .

On the other hand, I did found the generated_width and generated_height
properties in the Image structure but I think they might be bound to
images generated by blender itself and they are not used when texture
images are loaded from file. So I modify the function called
image_initialize_after_load where we can update these 2 properties (c.f.
the "quick-and-dirty" patch joined in the mail) and now I can access
them in python .

I think there is a better way to do that and I'll take a look into 2.4x
code to found how it was done .

Cheers,

-- 
Kevin Roy
http://blog.knokorpo.fr

-------------- next part --------------
Index: source/blender/blenkernel/intern/image.c
===================================================================
--- source/blender/blenkernel/intern/image.c	(révision 25732)
+++ source/blender/blenkernel/intern/image.c	(copie de travail)
@@ -1648,6 +1648,8 @@ static void image_initialize_after_load(Image *ima
 		if(ima->flag & IMA_STD_FIELD) de_interlace_st(ibuf);
 		else de_interlace_ng(ibuf);
 	}
+	ima->gen_x = ibuf->x;
+	ima->gen_y = ibuf->y;
 	/* timer */
 	ima->lastused = clock() / CLOCKS_PER_SEC;
 	


More information about the Bf-committers mailing list