Re: [Bf-committers] bpy.Image memoryview problems

2010-05-27 Thread Philipp Oeser
Hi list, sorry if this is the wrong place to articulate an uneducated wish. I was recently playing around with pyOpenCV, pyOpenGL, pygame and the like. What I found in those libraries is the ability to pass around pixel buffers in the form of a raw string meaning they are all able to convert from

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-07 Thread Campbell Barton
On Wed, May 5, 2010 at 9:35 AM, Theo de Ridder wrote: > > On 5 mei 2010, at 07:53, Campbell wrote: > >> indeed it seems there is no way to get a PyCapsule into ctypes. >> Since this was the purpose, as_pointer() could return an 'int' which >> ctypes can convert into a pointer. >> >> as for securit

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-05 Thread Theo de Ridder
On 5 mei 2010, at 07:53, Campbell wrote: > indeed it seems there is no way to get a PyCapsule into ctypes. > Since this was the purpose, as_pointer() could return an 'int' which > ctypes can convert into a pointer. > > as for security, there are probably easier ways to exploit blender > then get

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-04 Thread Campbell Barton
On Wed, May 5, 2010 at 3:59 AM, Dan Eicher wrote: > On Tue, May 4, 2010 at 2:06 AM, Theo de Ridder > wrote: > >> >> On 4 mei 2010, at 08:13, Campbell wrote: >> >> > class Image(bpy_types.ID): >> >    def buffer_get(self, type="byte", frame=None): >> >        return None # replace with ctypes/buff

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-04 Thread Dan Eicher
On Tue, May 4, 2010 at 2:06 AM, Theo de Ridder wrote: > > On 4 mei 2010, at 08:13, Campbell wrote: > > > class Image(bpy_types.ID): > >def buffer_get(self, type="byte", frame=None): > >return None # replace with ctypes/buffer stuff. > > > > After this you can do.. > > buffer = bpy.dat

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-04 Thread Theo de Ridder
On 4 mei 2010, at 08:13, Campbell wrote: > class Image(bpy_types.ID): >def buffer_get(self, type="byte", frame=None): >return None # replace with ctypes/buffer stuff. > > After this you can do.. > buffer = bpy.data.images["foo"].buffer_get() I tried this, by adding those lines in t

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-03 Thread Campbell Barton
For experimenting, defining a type for an image is trivial. The way it works is bpy_types.py has its classes used when available, otherwise the C/API creates a class its self. All you'd need to do is... class Image(bpy_types.ID): def buffer_get(self, type="byte", frame=None): return

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-02 Thread Dan Eicher
> - An Image has float and int buffers, so we cant assume one buffer per > image > - An image has imbuf's for different frames of an image sequence. > Could add a method that returns a memory view object that deals with frames, layers and such instead of exporting it directly or add different memo

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-02 Thread Campbell Barton
On Mon, May 3, 2010 at 1:08 AM, Dan Eicher wrote: > On Sun, May 2, 2010 at 1:32 PM, Campbell Barton wrote: > >> >> Hi, I didnt realize this was possible but you should be able to add >> image access without any C changes using the as_pointer() function. >> pt = bpy.data.images["Image"].as_pointer(

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-02 Thread Dan Eicher
On Sun, May 2, 2010 at 1:32 PM, Campbell Barton wrote: > > Hi, I didnt realize this was possible but you should be able to add > image access without any C changes using the as_pointer() function. > pt = bpy.data.images["Image"].as_pointer() > > >From here you should be able to use pure python wit

Re: [Bf-committers] bpy.Image memoryview problems

2010-05-02 Thread Campbell Barton
On Sun, May 2, 2010 at 9:39 PM, Dan Eicher wrote: > 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']) i

[Bf-committers] bpy.Image memoryview problems

2010-05-02 Thread Dan Eicher
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)