@@ -153,27 +153,23 @@ def draw_image(self, x, y, im, bbox):
153
153
# bbox - not currently used
154
154
if _debug : print '%s.%s()' % (self .__class__ .__name__ , _fn_name ())
155
155
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
-
166
156
im .flipud_out ()
167
157
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 ()
171
162
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 )
175
164
surface = cairo .ImageSurface .create_for_data (X , cairo .FORMAT_ARGB32 ,
176
165
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
177
173
ctx .set_source_surface (surface , x , y )
178
174
ctx .paint ()
179
175
0 commit comments