I have looked everywhere and am pretty stumped I can’t seem to find the answer to this. Is there a way of getting the texture currently active in the UV/ Image Editor without going through the mesh?
I’m working with a custom file format and while the model export works fine it would be nice to be able to export only a texture. Note that I’m saying a texture; this does not nescesarily have to be the one applied to the currently selected mesh.
The API docs do mention a context.texture member, but this doesn’t seem to exist. Any thoughts?
Imagel.pixels is a flat array, containing RGBA values. You should really use a copy of the data, as the access is otherwise slow as hell.
p = space_data.image.pixels[:]
Use a little formula for the pixel number:
pixelNumber = (image_size_x * y_co) + x_co
The pixel number is equal to the red component, greens is +1, blue +2 and alpha +3:
r = p[pixelNumber4]
g = p[pixelNumber4 + 1]
b = p[pixelNumber4 + 2]
a = p[pixelNumber4 + 3]