I store image’s pixels in a single multiprocessing.Array of integers which can be indexed as
self.data[x*height + y]
as this is convenient to use with IPC.
I’m trying to save the pixels to a file using PIL’s putdata() to make it faster than using putpixel() or the [] indexing. However I cannot figure out in which format does putdata() want the imagedata.
I thought the same type of indexing would work with putdata()
def write(self):
im = Image.new("RGB", (self.width, self.height))
imagedata = [self.intToRGB(self.data[i*self.height + j])
for i in range(self.width)
for j in range(self.height)]
im.putdata(imagedata)
im.save(self.filename, "PNG")
self.intToRGB() returns a tuple(r, g, b).
But the code above results to a -90 degrees turned image with a lot of repetition.

If I use putpixel() instead of putdata() like this:
pic = im.load()
for i in range(self.width):
offset = i * self.height
for j in range(self.height):
pic[i, j] = imagedata[i * self.height + j]
it produces

I think I see the problem in your first line:
Image data is generally organized the other way around: