Hi,
I can figure the first steps :
something like :

           matrix = []
           buffer = self.get_renderer().tostring_argb()
           l, h = self.GetSize()
           for ligne in xrange(h):
               matrix.append([])
               for colonne in xrange(l):
                   i = 4*(ligne*h + colonne)
                   pixel = buffer[i:i+4]
                   matrix[-1].append(pixel)
           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
facilities.
r = RendererAgg(pixelx1 - pixelx0, pixely1 - pixely0, Value(dpi))
...
r._renderer.write_png(nom)

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,

Nicolas



How may I transform my buffer into an image ?
On 6/28/07, John Hunter <[EMAIL PROTECTED]> wrote:

On 6/28/07, Nicolas <[EMAIL PROTECTED]> 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.

Thanks,
JDH

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to