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

Skip to content

Commit 31f9b15

Browse files
author
Steve Chaplin
committed
SC
svn path=/trunk/matplotlib/; revision=2980
1 parent 072f173 commit 31f9b15

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
2007-01-12 backend_cairo.py: fix draw_image() so that examples/image_demo.py
2+
now looks correct - SC
3+
14
2007-01-11 Added Axes.xcorr and Axes.acorr to plot the cross
25
correlation of x vs y or the autocorrelation of x. pylab
36
wrappers also provided. See examples/xcorr_demo.py - JDH

lib/matplotlib/backends/backend_cairo.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -153,27 +153,23 @@ 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
160-
161-
#if not HAVE_CAIRO_NUMPY:
162-
# warnings.warn("cairo with Numeric support is required for "
163-
# "draw_image()")
164-
# return
165-
166156
im.flipud_out()
167157

168-
rows, cols, buf = im.buffer_argb32() # ARGB32, but colors still wrong
169-
X = numx.fromstring (buf, numx.UInt8)
170-
X.shape = rows, cols, 4
158+
if sys.byteorder == 'little':
159+
rows, cols, str_ = im.buffer_bgra32()
160+
else:
161+
rows, cols, str_ = im.buffer_argb32()
171162

172-
# function does not pass a 'gc' so use renderer.ctx
173-
ctx = self.ctx
174-
#surface = cairo.ImageSurface.create_for_array (X)
163+
X = numx.fromstring (str_, numx.UInt8)
175164
surface = cairo.ImageSurface.create_for_data (X, cairo.FORMAT_ARGB32,
176165
rows, cols, rows*4)
166+
# It would be simpler if im.buffer_*() returned a writeable buffer
167+
# instead of a string, we could then bypass numx completely:
168+
#surface = cairo.ImageSurface.create_for_data (
169+
# str_, cairo.FORMAT_ARGB32, rows, cols, rows*4)
170+
171+
# function does not pass a 'gc' so use renderer.ctx
172+
ctx = self.ctx
177173
ctx.set_source_surface (surface, x, y)
178174
ctx.paint()
179175

0 commit comments

Comments
 (0)