From: <jd...@us...> - 2008-11-09 13:16:43
|
Revision: 6381 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=6381&view=rev Author: jdh2358 Date: 2008-11-09 13:16:39 +0000 (Sun, 09 Nov 2008) Log Message: ----------- fixed from_images to respect stride Modified Paths: -------------- trunk/matplotlib/examples/pylab_examples/figimage_demo.py trunk/matplotlib/examples/pylab_examples/layer_images.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-11-09 00:24:29 UTC (rev 6380) +++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-11-09 13:16:39 UTC (rev 6381) @@ -12,12 +12,12 @@ Z.shape = 100,100 Z[:,50:] = 1. -im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet, origin='upper') -im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet, origin='upper') +im1 = plt.figimage(Z, xo=50, yo=0, cmap=cm.jet, origin='lower') +im2 = plt.figimage(Z, xo=100, yo=100, alpha=.8, cmap=cm.jet, origin='lower') -fig.savefig('figimage_demo.png') -fig.savefig('figimage_demo.svg') -fig.savefig('figimage_demo.pdf') +#fig.savefig('figimage_demo.png') +#fig.savefig('figimage_demo.svg') +#fig.savefig('figimage_demo.pdf') plt.show() Modified: trunk/matplotlib/examples/pylab_examples/layer_images.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/layer_images.py 2008-11-09 00:24:29 UTC (rev 6380) +++ trunk/matplotlib/examples/pylab_examples/layer_images.py 2008-11-09 13:16:39 UTC (rev 6381) @@ -25,15 +25,17 @@ xmin, xmax, ymin, ymax = amin(x), amax(x), amin(y), amax(y) extent = xmin, xmax, ymin, ymax +fig = plt.figure(frameon=False) + Z1 = array(([0,1]*4 + [1,0]*4)*4); Z1.shape = 8,8 # chessboard im1 = imshow(Z1, cmap=cm.gray, interpolation='nearest', - extent=extent, origin='lower') + extent=extent) hold(True) Z2 = func3(X, Y) im2 = imshow(Z2, cmap=cm.jet, alpha=.9, interpolation='bilinear', - extent=extent, origin='lower') + extent=extent) #axis([xmin, xmax, ymin, ymax]) Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-11-09 00:24:29 UTC (rev 6380) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-11-09 13:16:39 UTC (rev 6381) @@ -1536,12 +1536,7 @@ ims = [(im.make_image(mag),0,0) for im in self.images if im.get_visible()] - #flip the images if their origin is "upper" - for _im, (im,_,_) in zip(self.images, ims): - if _im.origin=="upper": - im.flipud_out() - l, b, r, t = self.bbox.extents width = mag*((round(r) + 0.5) - (round(l) - 0.5)) height = mag*((round(t) + 0.5) - (round(b) - 0.5)) Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-11-09 00:24:29 UTC (rev 6380) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-11-09 13:16:39 UTC (rev 6381) @@ -753,11 +753,6 @@ ims = [(im.make_image(mag), im.ox*mag, im.oy*mag) for im in self.images] - for _im, (im,_,_) in zip(self.images, ims): - if _im.origin=="upper": - im.flipud_out() - - im = _image.from_images(self.bbox.height * mag, self.bbox.width * mag, ims) Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2008-11-09 00:24:29 UTC (rev 6380) +++ trunk/matplotlib/src/_image.cpp 2008-11-09 13:16:39 UTC (rev 6381) @@ -104,7 +104,9 @@ args.verify_length(0); int stride = rbufOut->stride(); + //std::cout << "flip before: " << rbufOut->stride() << std::endl; rbufOut->attach(bufferOut, colsOut, rowsOut, -stride); + //std::cout << "flip after: " << rbufOut->stride() << std::endl; return Py::Object(); } @@ -744,18 +746,24 @@ rb.clear(agg::rgba(1, 1, 1, 1)); - for (size_t imnum=0; imnum< N; imnum++) { tup = Py::Tuple(tups[imnum]); Image* thisim = static_cast<Image*>(tup[0].ptr()); ox = Py::Int(tup[1]); oy = Py::Int(tup[2]); - + bool isflip = (thisim->rbufOut->stride())<0; + //std::cout << "from images " << isflip << "; stride=" << thisim->rbufOut->stride() << std::endl; size_t ind=0; for (size_t j=0; j<thisim->rowsOut; j++) { for (size_t i=0; i<thisim->colsOut; i++) { thisx = i+ox; - thisy = j+oy; + + if (isflip) + thisy = thisim->rowsOut - j + oy; + else + thisy = j+oy; + + if (thisx>=numcols || thisy>=numrows) { ind +=4; continue; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |