allocation of pixel buffer

[email protected] (Chris Barker - NOAA Federal) Wed, 19 Jun 2013 12:31:36 -0700
Newsgroups php.gd.devel
Message-ID <CALGmxELtZCMKB4RLG_i4uT=cuEdrhJZzK0jKHB8mrLDSF_L_xQ@mail.gmail.com>
Folks,

I'm working on some new bindings of GD for Python. One of the things
I'd hoped to do is wrap the pixel buffer in a numpy array, so that
users could manipulate it with numpy functions (and nifty tools like
the nd-image package) and not have to copy the data back-and forthc
between gd and numpy.

However, I've noticed that the pixel buffer is allocated row-by-row,
rather than as oen big block of data. This make it impossible to share
the buffer with numpy, as numpy requires a single block of contiguous
memory.

It there a compelling reason for it to be allocated this way? or could
I re-write the allocation routines to allocate a single block of
memory? (still casting it to a **, so it would still be able to be
used in the same way in the rest of the code.

Honestly, I'm not sure I'd ever get around to it -- copying data isn't
all THAT expensive, but I was wondering if it's done this way for a
godo reason I'm not thinking of at the moment.

-Chris



-- 

Christopher Barker, Ph.D.
Oceanographer

Emergency Response Division
NOAA/NOS/OR&R            (206) 526-6959   voice
7600 Sand Point Way NE   (206) 526-6329   fax
Seattle, WA  98115       (206) 526-6317   main reception

[email protected]