Pillow icon indicating copy to clipboard operation
Pillow copied to clipboard

WIP Allow new-style buffer interfaces to be read/write

Open wiredfool opened this issue 7 years ago • 1 comments

Fixes #2973.

Changes proposed in this pull request:

  • Allow buffers to be read/write for at least the array interface, and possibly some mmapd files in the future. This opens up bidirectional communication with numpy arrays through shared memory.

I believe that the reason that it wasn't read/write was probably historical and tied to the old buffer interface, as mmap and the new style buffer interface don't play nicely on 2.7. As I'm not sure of the reason that it's this way, I'm a little cautious of opening this up without reasonably serious checking.

(also, tests, docs, etc)

wiredfool avatar Jan 25 '18 21:01 wiredfool

When this pull request will be merged? My graphics program is heavily affected by memcpy and this feature is the issue killer.

I've tried your folk however the problem seems not sovled yet, sudo pip3 install "git+https://github.com/wiredfool/Pillow.git@buffer-updates"

        drawable = canvas.get_drawable()
        im = Image.frombuffer('RGB', drawable.shape[:2][::-1], np.frombuffer(drawable), 'raw', 'RGB', 0, 1)

Any drawing on im is not updated to drawable. Any idea? Or because mode 'RGB' is not supported by Image.frombuffer, see https://pillow.readthedocs.io/en/3.1.x/reference/Image.html#PIL.Image.fromstring ?

vodp avatar Nov 08 '19 09:11 vodp