|
From: <md...@us...> - 2010-07-28 18:33:17
|
Revision: 8585
http://matplotlib.svn.sourceforge.net/matplotlib/?rev=8585&view=rev
Author: mdboom
Date: 2010-07-28 18:33:11 +0000 (Wed, 28 Jul 2010)
Log Message:
-----------
Fix problems displaying images with zero (logical) width.
Modified Paths:
--------------
branches/v1_0_maint/lib/matplotlib/image.py
branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg
branches/v1_0_maint/src/_image.cpp
Modified: branches/v1_0_maint/lib/matplotlib/image.py
===================================================================
--- branches/v1_0_maint/lib/matplotlib/image.py 2010-07-27 17:28:58 UTC (rev 8584)
+++ branches/v1_0_maint/lib/matplotlib/image.py 2010-07-28 18:33:11 UTC (rev 8585)
@@ -147,8 +147,14 @@
dyintv = ymax-ymin
# the viewport scale factor
- sx = dxintv/viewlim.width
- sy = dyintv/viewlim.height
+ if viewlim.width == 0.0 and dxintv == 0.0:
+ sx = 1.0
+ else:
+ sx = dxintv/viewlim.width
+ if viewlim.height == 0.0 and dyintv == 0.0:
+ sy = 1.0
+ else:
+ sy = dyintv/viewlim.height
numrows, numcols = A.shape[:2]
if sx > 2:
x0 = (viewlim.x0-xmin)/dxintv * numcols
@@ -576,9 +582,17 @@
im.set_resample(self._resample)
# the viewport translation
- tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
- ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
+ if dxintv == 0.0:
+ tx = 0.0
+ else:
+ tx = (xmin-transformed_viewLim.x0)/dxintv * numcols
+ if dyintv == 0.0:
+ ty = 0.0
+ else:
+ ty = (ymin-transformed_viewLim.y0)/dyintv * numrows
+ im.apply_translation(tx, ty)
+
l, b, r, t = self.axes.bbox.extents
widthDisplay = (round(r*magnification) + 0.5) - (round(l*magnification) - 0.5)
heightDisplay = (round(t*magnification) + 0.5) - (round(b*magnification) - 0.5)
@@ -586,7 +600,7 @@
# resize viewport to display
rx = widthDisplay / numcols
- ry = heightDisplay / numrows
+ ry = heightDisplay / numrows
im.apply_scaling(rx*sx, ry*sy)
im.resize(int(widthDisplay+0.5), int(heightDisplay+0.5),
norm=self._filternorm, radius=self._filterrad)
Modified: branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg
===================================================================
--- branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg 2010-07-27 17:28:58 UTC (rev 8584)
+++ branches/v1_0_maint/lib/matplotlib/tests/baseline_images/test_image/image_clip.svg 2010-07-28 18:33:11 UTC (rev 8585)
@@ -25,7 +25,19 @@
C122.400000 261.827096 140.607298 305.783402 173.011948 338.188052
C205.416598 370.592702 249.372904 388.800000 295.200000 388.800000z"/>
</g>
-<image x="122.400000" y="41.800000" width="347.000000" height="347.000000" xlink:href="data:image/png;base64,
+<defs>
+ <clipPath id="p904278a4c1c81ab8b13ccb57b319fa38">
+<path d="M295.200000 388.800000
+C341.027096 388.800000 384.983402 370.592702 417.388052 338.188052
+C449.792702 305.783402 468.000000 261.827096 468.000000 216.000000
+C468.000000 170.172904 449.792702 126.216598 417.388052 93.811948
+C384.983402 61.407298 341.027096 43.200000 295.200000 43.200000
+C249.372904 43.200000 205.416598 61.407298 173.011948 93.811948
+C140.607298 126.216598 122.400000 170.172904 122.400000 216.000000
+C122.400000 261.827096 140.607298 305.783402 173.011948 338.188052
+C205.416598 370.592702 249.372904 388.800000 295.200000 388.800000z"/>
+ </clipPath>
+</defs><image x="122.400000" y="41.800000" width="347.000000" height="347.000000" clip-path="url(#p904278a4c1c81ab8b13ccb57b319fa38)" xlink:href="data:image/png;base64,
iVBORw0KGgoAAAANSUhEUgAAAVsAAAFbCAYAAAB7zy3tAAAABHNCSVQICAgIfAhkiAAAIABJREFU
eJztfeGS4zzLLNp67vvc+XJ+WECDkJ2ZjTJvfdNdtRtbQggpcbuNZc8Q+X8qxPsxhsiwzyHy54v7
Q64ygbq6/6++v9LXru+dr+/sC2z/edh/1fd35uex73+Y++98z9/9HXz1u5DLLXEGf346AIIgiN8A
@@ -608,7 +620,7 @@
</g>
<g id="ytick8">
<g id="text19">
-<g style="fill: #000000; opacity: 1.000000" transform="translate(118.332060,125.327188)scale(0.120000)">
+<g style="fill: #000000; opacity: 1.000000" transform="translate(118.332060,125.327187)scale(0.120000)">
<use xlink:href="#c_3dcfa38a02242cb63ec6726c6e70be7a"/>
<use xlink:href="#c_7a2040fe3b94fcd41d0a72c84e93b115" x="63.623047"/>
<use xlink:href="#c_40880da00a2fb346f185ce8104650367" x="127.246094"/>
Modified: branches/v1_0_maint/src/_image.cpp
===================================================================
--- branches/v1_0_maint/src/_image.cpp 2010-07-27 17:28:58 UTC (rev 8584)
+++ branches/v1_0_maint/src/_image.cpp 2010-07-28 18:33:11 UTC (rev 8585)
@@ -392,7 +392,6 @@
// the image path
agg::path_storage path;
- agg::int8u *bufferPad = NULL;
agg::rendering_buffer rbufPad;
double x0, y0, x1, y1;
@@ -541,9 +540,7 @@
}
- delete [] bufferPad;
return Py::Object();
-
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|