On Nov 12, 2009, at 4:32 PM, Jae-Joon Lee wrote:
> shape = fig.canvas.get_width_height()[::-1] + (4,)
>
> im = np.frombuffer(fig.canvas.buffer_rgba(0,0),
> dtype=np.uint8).reshape(shape)
>
> Using buffer_rgba is more efficient than using tostring_rgb as no
> memory is allocated. But, I believe that "im" is a read-only "view" of
> the canvas. So, you must make a copy if you want to show it with
> imshow as in your original code.
>
> If you're using PIL,
>
> import PIL.Image
>
> im2=PIL.Image.frombuffer("RGBA", fig.canvas.get_width_height(),
> fig.canvas.buffer_rgba(0,0), "raw", "RGBA",
> 0, 1)
Work perfectly. Thanks, JJ!
-Geoff
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users