Revision: 5300
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5300&view=rev
Author: mdboom
Date: 2008-05-29 07:57:15 -0700 (Thu, 29 May 2008)
Log Message:
-----------
Merged revisions 5295-5299 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v0_91_maint
........
r5298 | mdboom | 2008-05-29 09:01:40 -0400 (Thu, 29 May 2008) | 2 lines
Implement path clipping in SVG backend.
........
r5299 | dsdale | 2008-05-29 09:54:04 -0400 (Thu, 29 May 2008) | 3 lines
fixed two bugs in texmanager: dvipng version comparison, and
another related to the addition of the get_gray method
........
Modified Paths:
--------------
trunk/matplotlib/CHANGELOG
trunk/matplotlib/lib/matplotlib/texmanager.py
Property Changed:
----------------
trunk/matplotlib/
Property changes on: trunk/matplotlib
___________________________________________________________________
Name: svnmerge-integrated
- /branches/v0_91_maint:1-5294
+ /branches/v0_91_maint:1-5299
Modified: trunk/matplotlib/CHANGELOG
===================================================================
--- trunk/matplotlib/CHANGELOG 2008-05-29 13:54:04 UTC (rev 5299)
+++ trunk/matplotlib/CHANGELOG 2008-05-29 14:57:15 UTC (rev 5300)
@@ -1,3 +1,10 @@
+2008-05-29 Fixed two bugs in texmanager.py:
+ improved comparison of dvipng versions
+ fixed a bug introduced when get_grey method was added
+ - DSD
+
+2008-05-29 Implement path clipping in SVG backend - MGD
+
2008-05-28 Fix crashing of PDFs in xpdf and ghostscript when two-byte
characters are used with Type 3 fonts - MGD
Modified: trunk/matplotlib/lib/matplotlib/texmanager.py
===================================================================
--- trunk/matplotlib/lib/matplotlib/texmanager.py 2008-05-29 13:54:04 UTC
(rev 5299)
+++ trunk/matplotlib/lib/matplotlib/texmanager.py 2008-05-29 14:57:15 UTC
(rev 5300)
@@ -33,7 +33,8 @@
"""
-import copy, glob, md5, os, shutil, sys
+import copy, glob, md5, os, shutil, sys, warnings
+import distutils.version
import numpy as np
import matplotlib as mpl
from matplotlib import rcParams
@@ -44,14 +45,15 @@
if sys.platform.startswith('win'): cmd_split = '&'
else: cmd_split = ';'
-def get_dvipng_version():
+def dvipng_hack_alpha():
stdin, stdout = os.popen4('dvipng -version')
for line in stdout:
if line.startswith('dvipng '):
version = line.split()[-1]
mpl.verbose.report('Found dvipng version %s'% version,
'helpful')
- return version
+ version = distutils.version.LooseVersion(version)
+ return version < distutils.version.LooseVersion('1.6')
raise RuntimeError('Could not obtain dvipng version')
@@ -78,7 +80,7 @@
if not os.path.exists(texcache):
os.mkdir(texcache)
- dvipngVersion = get_dvipng_version()
+ _dvipng_hack_alpha = dvipng_hack_alpha()
# mappable cache of
rgba_arrayd = {}
@@ -364,8 +366,28 @@
pngfile = self.make_png(tex, fontsize, dpi)
X = readpng(os.path.join(self.texcache, pngfile))
- if (self.dvipngVersion < '1.6') or rcParams['text.dvipnghack']:
- # hack the alpha channel as described in comment above
+ if self._dvipng_hack_alpha or rcParams['text.dvipnghack']:
+ # hack the alpha channel
+ # dvipng assumed a constant background, whereas we want to
+ # overlay these rasters with antialiasing over arbitrary
+ # backgrounds that may have other figure elements under them.
+ # When you set dvipng -bg Transparent, it actually makes the
+ # alpha channel 1 and does the background compositing and
+ # antialiasing itself and puts the blended data in the rgb
+ # channels. So what we do is extract the alpha information
+ # from the red channel, which is a blend of the default dvipng
+ # background (white) and foreground (black). So the amount of
+ # red (or green or blue for that matter since white and black
+ # blend to a grayscale) is the alpha intensity. Once we
+ # extract the correct alpha information, we assign it to the
+ # alpha channel properly and let the users pick their rgb. In
+ # this way, we can overlay tex strings on arbitrary
+ # backgrounds with antialiasing
+ #
+ # red = alpha*red_foreground + (1-alpha)*red_background
+ #
+ # Since the foreground is black (0) and the background is
+ # white (1) this reduces to red = 1-alpha or alpha = 1-red
alpha = np.sqrt(1-X[:,:,0])
else:
alpha = X[:,:,-1]
@@ -378,26 +400,6 @@
"""
Returns latex's rendering of the tex string as an rgba array
"""
- # dvipng assumes a constant background, whereas we want to
- # overlay these rasters with antialiasing over arbitrary
- # backgrounds that may have other figure elements under them.
- # When you set dvipng -bg Transparent, it actually makes the
- # alpha channel 1 and does the background compositing and
- # antialiasing itself and puts the blended data in the rgb
- # channels. So what we do is extract the alpha information
- # from the red channel, which is a blend of the default dvipng
- # background (white) and foreground (black). So the amount of
- # red (or green or blue for that matter since white and black
- # blend to a grayscale) is the alpha intensity. Once we
- # extract the correct alpha information, we assign it to the
- # alpha channel properly and let the users pick their rgb. In
- # this way, we can overlay tex strings on arbitrary
- # backgrounds with antialiasing
- #
- # red = alpha*red_foreground + (1-alpha)*red_background
- #
- # Since the foreground is black (0) and the background is
- # white (1) this reduces to red = 1-alpha or alpha = 1-red
if not fontsize: fontsize = rcParams['font.size']
if not dpi: dpi = rcParams['savefig.dpi']
r,g,b = rgb
@@ -407,7 +409,8 @@
if Z is None:
alpha = self.get_grey(tex, fontsize, dpi)
- Z = np.zeros((X.shape[0], X.shape[1], 4), np.float)
+ Z = np.zeros((alpha.shape[0], alpha.shape[1], 4), np.float)
+
Z[:,:,0] = r
Z[:,:,1] = g
Z[:,:,2] = b
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
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-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-checkins