[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] BufferProxy (was Flood Filling Images)



hi,

BufferProxy is not only usable from C - but from python too.  numpy
support is implemented in python on top of the BufferProxy.

Modularity is one reason these things are kept separate.  Each part
has a separate concern, so they are separated.  To simplify each, and
so that if you don't need to use each part, you don't have to.  Also
PixelArray is still experimental and still changing, where as Surface
is really quite unchanging, and BufferProxy is unlikely to change that
much.

Also getting a buffer proxy helps with surface locking semantics.
When you get a BufferProxy the surface is locked (which you need to do
when you are modifying Surface->pixels - when the BufferProxy is
destroyed, the surface lock is released.


cheers,


On Wed, Apr 16, 2008 at 8:43 AM, Greg Ewing <greg.ewing@xxxxxxxxxxxxxxxx> wrote:
> Marcus von Appen wrote:
>
> > BufferProxy is just a simple interface to the surface pixels so
> > other systems like e.g. numpy can (ab)use surfaces pixels easily without
> > the need to write C code for them.
> >
>
>  If it's only usable from C, then why does it exist?
>  Why can't the surface just implement the buffer
>  interface directly?
>
>  --
>  Greg
>