John Hunter skrev:
On Fri, May 16, 2008 at 1:46 PM, Jörgen Stenarson
<[EMAIL PROTECTED]> wrote:
Hi,
with current svn (r5149) I get currupt png files when saving using
pylab.savefig. I'm using the TkAgg backend with no changes to the default
matplotlibrc. It looks like the problem occurs first with r5026. I have
attached pngs generated using the same script for r5025, r5026, and r5149.
This appears to be the relevant changeset :
http://matplotlib.svn.sourceforge.net/viewvc/matplotlib/trunk/matplotlib/src/_backend_agg.cpp?r1=4929&r2=5026
you have some time to poke through the changes, perhaps you can find
out what is wrong for your platform. We are a bit short on win32
developers who have access to svn right now.
It turned out it was easier than some obscure windows related c++ bug.
The changes in backend_agg.py creates a file handle in text mode and not
binary mode which results in corrupted files on windows. The attached
patch fixed the problem for me.
/Jörgen
Index: lib/matplotlib/backends/backend_agg.py
===================================================================
--- lib/matplotlib/backends/backend_agg.py (revision 5169)
+++ lib/matplotlib/backends/backend_agg.py (working copy)
@@ -290,7 +290,7 @@
original_dpi = renderer.dpi
renderer.dpi = self.figure.dpi
if type(filename_or_obj) in (str, unicode):
- filename_or_obj = open(filename_or_obj, 'w')
+ filename_or_obj = open(filename_or_obj, 'wb')
renderer._renderer.write_rgba(filename_or_obj)
renderer.dpi = original_dpi
print_rgba = print_raw
@@ -301,6 +301,6 @@
original_dpi = renderer.dpi
renderer.dpi = self.figure.dpi
if type(filename_or_obj) in (str, unicode):
- filename_or_obj = open(filename_or_obj, 'w')
+ filename_or_obj = open(filename_or_obj, 'wb')
self.get_renderer()._renderer.write_png(filename_or_obj,
self.figure.dpi)
renderer.dpi = original_dpi
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users