[Bf-committers] RE: [Bf-python] New Python Function - Patch
Brecht Van Lommel
blendix at pandora.be
Tue Feb 22 15:45:37 CET 2005
On 22 Feb 2005, at 15:22, Martin Poirier wrote:
>>
>> Just a random comment: I would think that such a
>> method to access single
>> pixel values with one function call per pixel is
>> pretty useless unless you
>> have a supercomputer.
>>
>> What would probably be much more useful is a
>> function returning a whole
>> array (or whatever it's called in python) instead of
>> a single pixel.
>
> Actually, what would be nice is if it would return a
> python wrapper around the ImBuf that overloaded the []
> operator to access single elements [(x,y)] and slices
> [(x1,y1):(x2,y2)]. Just a silly thought.
I once hacked together a patch that did a similar thing for a verse
demo. It allowed me to do opengl-style readPixels and drawPixels on an
image, using a python Buffer object. This was nicely compatible with
BGL (which also uses Buffer objects), and allows [x][y] acces on the
buffer.
A disadvantage is that this means you first have to read the pixels
from the image to the buffer, then modify the buffer, and then write
them back again, instead of direct access.
The patch is more than a year old, and wasn't tested very well, but it
might be useful to someone who wants to implement this:
http://users.pandora.be/blendix/verse/old/patch_gimp.txt
Brecht.
More information about the Bf-committers
mailing list