[Bf-committers] bpy.Image memoryview problems

Dan Eicher dan at trollwerks.org
Sun May 2 21:39:39 CEST 2010


Been working on a py_buffer method for pixel access (
http://www.pasteall.org/12868/diff) and can't seem to figure out where it
goes wrong.

It appears to work...

>>> import bpy
>>> img = memoryview(bpy.data.images['Lenna.png'])
>>> img.format
'B'

>>> img.itemsize
1

>>> img.shape
(512, 512, 3)

>>> img.ndim
3

>>> img.strides
(1536, 3, 1)

but when trying to access pixels...

>>> img[0][0][0]
Traceback (most recent call last):
  File "<console>", line 1, in <module>
IndexError: invalid indexing of 0-dim memory

This whole thing is driving me batty since there's very little info on the
py_buffer method on the web.


More information about the Bf-committers mailing list