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

Skip to content

Commit 358855c

Browse files
committed
Image generation no longer generates double-precision rgba; patch by C. Gohlke
Image generation via color mapping was using doubles for rgba, after which the _image module was converting rgba to uint8; this patch saves time and memory by using the existing ability of the colormap to generate uint8 directly. svn path=/trunk/matplotlib/; revision=8945
1 parent aabb275 commit 358855c

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

CHANGELOG

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
2011-02-04 Changed imshow to use rgba as uint8 from start to
2+
finish, instead of going through an intermediate
3+
step as double precision; thanks to Christoph Gohlke. - EF
4+
15
2011-01-13 Added zdir and offset arguments to contourf3d to
26
bring contourf3d in feature parity with contour3d. - BVR
37

@@ -8,7 +12,7 @@
812
2011-01-03 Turn off tick labeling on interior subplots for
913
pyplots.subplots when sharex/sharey is True. - JDH
1014

11-
2010-12-29 Implment axes_divider.HBox and VBox. -JJL
15+
2010-12-29 Implement axes_divider.HBox and VBox. -JJL
1216

1317

1418
2010-11-22 Fixed error with Hammer projection. - BVR

lib/matplotlib/image.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def make_image(self, magnification=1.0):
138138
def _get_unsampled_image(self, A, image_extents, viewlim):
139139
"""
140140
convert numpy array A with given extents ([x1, x2, y1, y2] in
141-
data coordinate) into the Image, given the vielim (should be a
141+
data coordinate) into the Image, given the viewlim (should be a
142142
bbox instance). Image will be clipped if the extents is
143143
significantly larger than the viewlim.
144144
"""
@@ -193,17 +193,17 @@ def _get_unsampled_image(self, A, image_extents, viewlim):
193193
self._oldyslice = yslice
194194

195195
if self._imcache is None:
196-
if self._A.dtype == np.uint8 and len(self._A.shape) == 3:
196+
if self._A.dtype == np.uint8 and self._A.ndim == 3:
197197
im = _image.frombyte(self._A[yslice,xslice,:], 0)
198198
im.is_grayscale = False
199199
else:
200200
if self._rgbacache is None:
201-
x = self.to_rgba(self._A, self._alpha)
201+
x = self.to_rgba(self._A, self._alpha, bytes=True)
202202
self._rgbacache = x
203203
else:
204204
x = self._rgbacache
205-
im = _image.fromarray(x[yslice,xslice], 0)
206-
if len(self._A.shape) == 2:
205+
im = _image.frombyte(x[yslice,xslice,:], 0)
206+
if self._A.ndim == 2:
207207
im.is_grayscale = self.cmap.is_gray()
208208
else:
209209
im.is_grayscale = False

0 commit comments

Comments
 (0)