|
65 | 65 | cmd_split = ';' |
66 | 66 |
|
67 | 67 |
|
| 68 | +@mpl.cbook.deprecated("2.1") |
68 | 69 | def dvipng_hack_alpha(): |
69 | 70 | try: |
70 | 71 | p = Popen([str('dvipng'), '-version'], stdin=PIPE, stdout=PIPE, |
@@ -122,8 +123,6 @@ class TexManager(object): |
122 | 123 | if texcache is not None: |
123 | 124 | mkdirs(texcache) |
124 | 125 |
|
125 | | - _dvipng_hack_alpha = None |
126 | | - #_dvipng_hack_alpha = dvipng_hack_alpha() |
127 | 126 | # mappable cache of |
128 | 127 | rgba_arrayd = {} |
129 | 128 | grey_arrayd = {} |
@@ -542,46 +541,10 @@ def get_grey(self, tex, fontsize=None, dpi=None): |
542 | 541 | """returns the alpha channel""" |
543 | 542 | key = tex, self.get_font_config(), fontsize, dpi |
544 | 543 | alpha = self.grey_arrayd.get(key) |
545 | | - |
546 | 544 | if alpha is None: |
547 | 545 | pngfile = self.make_png(tex, fontsize, dpi) |
548 | 546 | X = read_png(os.path.join(self.texcache, pngfile)) |
549 | | - |
550 | | - if rcParams['text.dvipnghack'] is not None: |
551 | | - hack = rcParams['text.dvipnghack'] |
552 | | - else: |
553 | | - if TexManager._dvipng_hack_alpha is None: |
554 | | - TexManager._dvipng_hack_alpha = dvipng_hack_alpha() |
555 | | - hack = TexManager._dvipng_hack_alpha |
556 | | - |
557 | | - if hack: |
558 | | - # hack the alpha channel |
559 | | - # dvipng assumed a constant background, whereas we want to |
560 | | - # overlay these rasters with antialiasing over arbitrary |
561 | | - # backgrounds that may have other figure elements under them. |
562 | | - # When you set dvipng -bg Transparent, it actually makes the |
563 | | - # alpha channel 1 and does the background compositing and |
564 | | - # antialiasing itself and puts the blended data in the rgb |
565 | | - # channels. So what we do is extract the alpha information |
566 | | - # from the red channel, which is a blend of the default dvipng |
567 | | - # background (white) and foreground (black). So the amount of |
568 | | - # red (or green or blue for that matter since white and black |
569 | | - # blend to a grayscale) is the alpha intensity. Once we |
570 | | - # extract the correct alpha information, we assign it to the |
571 | | - # alpha channel properly and let the users pick their rgb. In |
572 | | - # this way, we can overlay tex strings on arbitrary |
573 | | - # backgrounds with antialiasing |
574 | | - # |
575 | | - # red = alpha*red_foreground + (1-alpha)*red_background |
576 | | - # |
577 | | - # Since the foreground is black (0) and the background is |
578 | | - # white (1) this reduces to red = 1-alpha or alpha = 1-red |
579 | | - #alpha = npy.sqrt(1-X[:,:,0]) # should this be sqrt here? |
580 | | - alpha = 1 - X[:, :, 0] |
581 | | - else: |
582 | | - alpha = X[:, :, -1] |
583 | | - |
584 | | - self.grey_arrayd[key] = alpha |
| 547 | + self.grey_arrayd[key] = alpha = X[:, :, -1] |
585 | 548 | return alpha |
586 | 549 |
|
587 | 550 | def get_rgba(self, tex, fontsize=None, dpi=None, rgb=(0, 0, 0)): |
|
0 commit comments