I seem to have a problem with reading pixel RGBA values (particularly alpha value) from a PNG image in Blender (with python).
I do the following:
for i in range(0, len(bpy.data.images["name_of_my_png"].pixels), 4):
print(bpy.data.images["name_of_my_png"].pixels[i:i+4]);
but I never really get any expected results for each pixel it prints out the same output - 1.0, 1.0, 1.0, 0.0
(I assume those are values of R,G,B and A respectively).
I'm pretty sure that the png is loaded in blender's cache, and that it is just a regular RGBA png image with both visible and invisible parts to it, so logically my printed output should contain some variation not just 1.0, 1.0, 1.0 and 0.0
constantly for each pixel...?
Could someone point out to me at what exactly I'm doing wrong? How do I read pixel data of an image through Blender-python at all? Maybe I am using a completely wrong approach?
Your code is working perfectly (tested with blender 2.71).
There are multiple possible explanations, why the output doesn't look like expected:
Save color values from transparent pixels
checkbox.r,g,b,a
channels, the image is stored by multiplying each color channel wit the alpha channel r*a, g*a, b*a, a
.