I can figure the first steps :
something like :
matrix = 
buffer = self.get_renderer().tostring_argb()
l, h = self.GetSize()
for ligne in xrange(h):
for colonne in xrange(l):
i = 4*(ligne*h + colonne)
pixel = buffer[i:i+4]
zone_to_export = array(matrix)[pixely0:pixely1, pixelx0:pixelx1]
new_buffer = buffer("".join("".join(elt for elt in ligne) for
ligne in zone_to_export ))
But then I don't know what to with this new buffer.
I tried to create a new RenderAgg instance, so as to use its png export
r = RendererAgg(pixelx1 - pixelx0, pixely1 - pixely0, Value(dpi))
But I don't know what to put between the two previous lines.
How may I load a buffer content into a RenderAgg instance ?
I suppose I may use something like :
r.draw_image(0, 0, im)
but what is the correct format for im ? Is there an Image class in
matplotlib (I looked for, but didn't find).
How may I convert my buffer ?
Thanks a lot,
How may I transform my buffer into an image ?
On 6/28/07, John Hunter <jdh2358@...> wrote:
> On 6/28/07, Nicolas <nico_75_0@...> wrote:
> > Thanks for your reply.
> > However, I don't want to had a PIL dependency.
> > Is there any other method, using only matplotlib or wx ?
> agg offers methods to convert the image pixel buffer to strings or
> buffers, which you could then convert to numpy arrays, so a slice
> extraction, and reconvert back to a buffer and ultimately a PNG. I
> don't have time right now to write some example code, but you may want
> to poke around in backend_agg to see if you can figure it out, and if
> not remind me next week.