I'm trying to use Python and the API to write out an imagefile (that i want to draw myself).
Somehow I cannot pass my pixel array to the MImage object - I don't know why it is not working. Whatever I pass it results in 1's only. Here is my code:
import maya.OpenMaya as om
img = om.MImage()
#make some test data
for i in range(1,10000) :
c= random.randint(1, 255)
#Pass to MImage as a Pointer
p = om.MScriptUtil()
img.setPixels(p.asUcharPtr(), 100, 100)
#Reading for testing
r = om.MScriptUtil()
ret = img.pixels()
for i in range(1,40000): ga.append(r.getUcharArrayItem(ret,i))
print ga # prints out a bunch of 1's
Thanks for any hints - its the first time i'm using something from the api, maybe i got something wrong..