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

Skip to content

Commit 9152332

Browse files
committed
Merged revisions 8585 via svnmerge from
https://matplotlib.svn.sf.net/svnroot/matplotlib/branches/v1_0_maint ........ r8585 | mdboom | 2010-07-28 14:33:11 -0400 (Wed, 28 Jul 2010) | 2 lines Fix problems displaying images with zero (logical) width. ........ svn path=/trunk/matplotlib/; revision=8586
1 parent c4e75e3 commit 9152332

File tree

3 files changed

+33
-10
lines changed

3 files changed

+33
-10
lines changed

lib/matplotlib/image.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ def _get_unsampled_image(self, A, image_extents, viewlim):
147147
dyintv = ymax-ymin
148148

149149
# the viewport scale factor
150-
sx = dxintv/viewlim.width
151-
sy = dyintv/viewlim.height
150+
if viewlim.width == 0.0 and dxintv == 0.0:
151+
sx = 1.0
152+
else:
153+
sx = dxintv/viewlim.width
154+
if viewlim.height == 0.0 and dyintv == 0.0:
155+
sy = 1.0
156+
else:
157+
sy = dyintv/viewlim.height
152158
numrows, numcols = A.shape[:2]
153159
if sx > 2:
154160
x0 = (viewlim.x0-xmin)/dxintv * numcols
@@ -576,8 +582,16 @@ def make_image(self, magnification=1.0):
576582
im.set_resample(self._resample)
577583

578584
# the viewport translation
579-
tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
580-
ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
585+
if dxintv == 0.0:
586+
tx = 0.0
587+
else:
588+
tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
589+
if dyintv == 0.0:
590+
ty = 0.0
591+
else:
592+
ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
593+
594+
im.apply_translation(tx, ty)
581595

582596
l, b, r, t = self.axes.bbox.extents
583597
widthDisplay = (round(r*magnification) + 0.5) - (round(l*magnification) - 0.5)
@@ -586,7 +600,7 @@ def make_image(self, magnification=1.0):
586600

587601
# resize viewport to display
588602
rx = widthDisplay / numcols
589-
ry = heightDisplay / numrows
603+
ry = heightDisplay / numrows
590604
im.apply_scaling(rx*sx, ry*sy)
591605
im.resize(int(widthDisplay+0.5), int(heightDisplay+0.5),
592606
norm=self._filternorm, radius=self._filterrad)

lib/matplotlib/tests/baseline_images/test_image/image_clip.svg

Lines changed: 14 additions & 2 deletions
Loading

src/_image.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,6 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)
392392

393393
// the image path
394394
agg::path_storage path;
395-
agg::int8u *bufferPad = NULL;
396395
agg::rendering_buffer rbufPad;
397396

398397
double x0, y0, x1, y1;
@@ -541,9 +540,7 @@ Image::resize(const Py::Tuple& args, const Py::Dict& kwargs)
541540

542541
}
543542

544-
delete [] bufferPad;
545543
return Py::Object();
546-
547544
}
548545

549546

0 commit comments

Comments
 (0)