8000 SC · matplotlib/matplotlib@7c5ac98 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7c5ac98

Browse files
author
Steve Chaplin
committed
SC
svn path=/trunk/matplotlib/; revision=2946
1 parent f8b9997 commit 7c5ac98

File tree

2 files changed

+33
-26
lines changed

2 files changed

+33
-26
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2006-12-27 backend_cairo.py: update draw_image() and _draw_mathtext() to work
2+
with numpy - SC
3+
14
2006-12-20 Fixed xpdf dependency check, which was failing on windows.
25
Removed ps2eps dependency check. - DSD
36

lib/matplotlib/backends/backend_cairo.py

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@ def _fn_name(): return sys._getframe(1).f_code.co_name
4242
from matplotlib.transforms import Bbox
4343

4444

45-
if hasattr (cairo.ImageSurface, 'create_for_array'):
46-
HAVE_CAIRO_NUMPY = True
47-
else:
48-
HAVE_CAIRO_NUMPY = False
45+
#if hasattr (cairo.ImageSurface, 'create_for_array'):
46+
# HAVE_CAIRO_NUMPY = True
47+
#else:
48+
# HAVE_CAIRO_NUMPY = False
4949

5050

5151
_debug = False
@@ -134,15 +134,15 @@ def draw_arc(self, gc, rgbFace, x, y, width, height, angle1, angle2, rotation):
134134
# FIXME
135135
# to get a proper arc of width/height you can use translate() and
136136
# scale(), see draw_arc() manual page
137-
137+
138138
#radius = (height + width) / 4
139139
ctx = gc.ctx
140140
ctx.save()
141141
ctx.rotate(rotation)
142142
ctx.scale(width / 2.0, height / 2.0)
143143
ctx.arc(0.0, 0.0, 1.0, 0.0, 2*numx.pi)
144144
ctx.restore()
145-
145+
146146
#ctx.new_path()
147147
#ctx.arc (x, self.height - y, radius,
148148
# angle1 * numx.pi/180.0, angle2 * numx.pi/180.0)
@@ -153,15 +153,15 @@ def draw_image(self, x, y, im, bbox):
153153
# bbox - not currently used
154154
if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
155155

156-
if numx.which[0] == "numarray":
157-
warnings.warn("draw_image() currently works for numpy, but not "
158-
"numarray")
159-
return
156+
#if numx.which[0] == "numarray":
157+
# warnings.warn("draw_image() currently works for numpy, but not "
158+
# "numarray")
159+
# return
160160

161-
if not HAVE_CAIRO_NUMPY:
162-
warnings.warn("cairo with Numeric support is required for "
163-
"draw_image()")
164-
return
161+
#if not HAVE_CAIRO_NUMPY:
162+
# warnings.warn("cairo with Numeric support is required for "
163+
# "draw_image()")
164+
# return
165165

166166
im.flipud_out()
167167

@@ -171,7 +171,9 @@ def draw_image(self, x, y, im, bbox):
171171

172172
# function does not pass a 'gc' so use renderer.ctx
173173
ctx = self.ctx
174-
surface = cairo.ImageSurface.create_for_array (X)
174+
#surface = cairo.ImageSurface.create_for_array (X)
175+
surface = cairo.ImageSurface.create_for_data (X, cairo.FORMAT_ARGB32,
176+
rows, cols, rows*4)
175177
ctx.set_source_surface (surface, x, y)
176178
ctx.paint()
177179

@@ -318,17 +320,17 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False):
318320

319321
def _draw_mathtext(self, gc, x, y, s, prop, angle):
320322
if _debug: print '%s.%s()' % (self.__class__.__name__, _fn_name())
321-
# mathtext using the gtk/gdk method
323+
# mathtext using the gtk/gdk method
322324

323-
if numx.which[0] == "numarray":
324-
warnings.warn("_draw_mathtext() currently works for numpy, but "
325-
"not numarray")
326-
return
325+
#if numx.which[0] == "numarray":
326+
# warnings.warn("_draw_mathtext() currently works for numpy, but "
327+
# "not numarray")
328+
# return
327329

328-
if not HAVE_CAIRO_NUMPY:
329-
warnings.warn("cairo with Numeric support is required for "
330-
"_draw_mathtext()")
331-
return
330+
#if not HAVE_CAIRO_NUMPY:
331+
# warnings.warn("cairo with Numeric support is required for "
332+
# "_draw_mathtext()")
333+
# return
332334

333335
size = prop.get_size_in_points()
334336
width, height, fonts = math_parse_s_ft2font(
@@ -364,8 +366,10 @@ def _draw_mathtext(self, gc, x, y, s, prop, angle):
364366
pa[:,:,2] = int(rgb[2]*255)
365367
pa[:,:,3] = Xs
366368

367-
# works for numpy pa, not a numarray pa
368-
surface = cairo.ImageSurface.create_for_array (pa)
369+
## works for numpy pa, not a numarray pa
370+
#surface = cairo.ImageSurface.create_for_array (pa)
371+
surface = cairo.ImageSurface.create_for_data (pa, cairo.FORMAT_ARGB32,
372+
imw, imh, imw*4)
369373
gc.ctx.set_source_surface (surface, x, y)
370374
gc.ctx.paint()
371375
#gc.ctx.show_surface (surface, imw, imh)

0 commit comments

Comments
 (0)
0