Skip to content

Commit

Permalink
Merge pull request #1193 from mdboom/cairo/alpha-handling
Browse files Browse the repository at this point in the history
Cairo backend ignores alpha in imshow.
  • Loading branch information
pelson committed Jan 28, 2014
2 parents 7466e06 + b81313a commit 7887018
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/matplotlib/backends/backend_cairo.py
Expand Up @@ -177,7 +177,10 @@ def draw_image(self, gc, x, y, im):

ctx.save()
ctx.set_source_surface (surface, x, y)
ctx.paint()
if gc.get_alpha() != 1.0:
ctx.paint_with_alpha(gc.get_alpha())
else:
ctx.paint()
ctx.restore()

im.flipud_out()
Expand Down Expand Up @@ -465,17 +468,17 @@ def _save (self, fo, format, **kwargs):
width_in_points)

if format == 'ps':
if not cairo.HAS_PS_SURFACE:
if not hasattr(cairo, 'PSSurface'):
raise RuntimeError ('cairo has not been compiled with PS '
'support enabled')
surface = cairo.PSSurface (fo, width_in_points, height_in_points)
elif format == 'pdf':
if not cairo.HAS_PDF_SURFACE:
if not hasattr(cairo, 'PDFSurface'):
raise RuntimeError ('cairo has not been compiled with PDF '
'support enabled')
surface = cairo.PDFSurface (fo, width_in_points, height_in_points)
elif format in ('svg', 'svgz'):
if not cairo.HAS_SVG_SURFACE:
if not hasattr(cairo, 'SVGSurface'):
raise RuntimeError ('cairo has not been compiled with SVG '
'support enabled')
if format == 'svgz':
Expand Down

0 comments on commit 7887018

Please sign in to comment.