Is there a way to access the pixel data of a texture?

Hello,

I was wondering if there is a way to get the pixel data of a texture (that would be the color for example). I need something to get the color information of a cloud texture (brightness information).
Something like this:

texture.getColor(x, y)

wich would then return the color (rgba-vector) of the pixel at position x, y

Does anybody know if and how that can be achieved?

Thanks in advance

basedow

http://lists.blender.org/pipermail/bf-blender-cvs/2011-April/035179.html

–>

http://www.blender.org/documentation/blender_python_api_2_57_release/bpy.types.Image.html?highlight=image.pixels#bpy.types.Image.pixels

for example:

bpy.data.textures['Tex'].image.pixels[0]
#or
bpy.data.images['logo-WIP.jpg'].pixels[0]

niko
.

Thank you - ill try it

basedow

i’m just writing a getPixelRGBA-function… should be ready any minute now…

niko
.

Ok - i have tried it.
It works for textures of type “Image”.
But i wanted it to work for textures of type “Cloud” for example. And if possible for all the other procedural textures that are build into Blender.
Python says that textures of type “Image” dont have an attribute called image - so there is no way to access image.pixels[].
Maybe the problem is that the procedural textures dont have a size - I mean they are endless and therefore it is tricky to allocate the memory for an array with size infinite. But maybe there is a way to get access to the algorithms that create the procedural textures.
I think ill give that one a try.
If anyone already knows how to achieve this - please let me know.

basedow

add a plane, apply the procedural texture, at the material settings goto shadow and set shadeless true. in the 3d-view go to the topview and press ctrl+alt+0(numpad) to set the camera. at the camera settings change perspective to orthographic and set the renderresolution to something 800:800 or whatever you need. render! then you have the image her: bpy.data.images[‘Render Result’]

you can write a script, if you need it for more than one texture…

niko
.