Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c05fd7a

Browse files
author
Steve Chaplin
committed
SC 12/02/2005
svn path=/trunk/matplotlib/; revision=963
1 parent d209133 commit c05fd7a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/matplotlib/backends/backend_cairo.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2):
128128

129129
def draw_image(self, x, y, im, origin, bbox):
130130
if DEBUG: print 'backend_cairo.RendererCairo.%s()' % _fn_name()
131-
# works for numpy image, not a numarray image
132131

133132
try: import cairo.numpy
134133
except:
@@ -155,8 +154,13 @@ def draw_image(self, x, y, im, origin, bbox):
155154
#X = fromstring(s, UInt8)
156155
#X.shape = rows, cols, 4
157156

158-
# ARGB32
159-
surface = cairo.numpy.surface_create_for_array (X)
157+
# ARGB32
158+
try:
159+
# works for numpy image, not a numarray image
160+
surface = cairo.numpy.surface_create_for_array (X)
161+
except TypeError, exc:
162+
verbose.report_error("%s: %s" % (_fn_name(), exc))
163+
return
160164

161165
# Alternative
162166
#surface = cairo.surface_create_for_image(buf, cairo.FORMAT_ARGB32, cols, rows) #, stride)

0 commit comments

Comments
 (0)