From: <jd...@us...> - 2008-06-22 10:25:47
|
Revision: 5618 http://matplotlib.svn.sourceforge.net/matplotlib/?rev=5618&view=rev Author: jdh2358 Date: 2008-06-20 10:09:12 -0700 (Fri, 20 Jun 2008) Log Message: ----------- added origin support for composite images Modified Paths: -------------- trunk/matplotlib/examples/api/mathtext_asarray.py trunk/matplotlib/examples/pylab_examples/figimage_demo.py trunk/matplotlib/lib/matplotlib/axes.py trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py trunk/matplotlib/lib/matplotlib/figure.py trunk/matplotlib/src/_gtkagg.cpp trunk/matplotlib/src/_image.cpp Modified: trunk/matplotlib/examples/api/mathtext_asarray.py =================================================================== --- trunk/matplotlib/examples/api/mathtext_asarray.py 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/examples/api/mathtext_asarray.py 2008-06-20 17:09:12 UTC (rev 5618) @@ -10,6 +10,7 @@ parser = mathtext.MathTextParser("Bitmap") + parser.to_png('test2.png', r'$\left[\left\lfloor\frac{5}{\frac{\left(3\right)}{4}} y\right)\right]$', color='green', fontsize=14, dpi=100) @@ -20,5 +21,4 @@ fig.figimage(rgba1.astype(float)/255., 100, 100) fig.figimage(rgba2.astype(float)/255., 100, 300) - plt.show() Modified: trunk/matplotlib/examples/pylab_examples/figimage_demo.py =================================================================== --- trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/examples/pylab_examples/figimage_demo.py 2008-06-20 17:09:12 UTC (rev 5618) @@ -13,8 +13,9 @@ im1 = figimage(Z, xo=50, yo=0) im2 = figimage(Z, xo=100, yo=100, alpha=.8) #gray() # overrides current and sets default -savefig('figimage_demo') +#savefig('figimage_demo') show() + Modified: trunk/matplotlib/lib/matplotlib/axes.py =================================================================== --- trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/axes.py 2008-06-20 17:09:12 UTC (rev 5618) @@ -1442,6 +1442,9 @@ im = mimage.from_images(height, width, ims) + if self.images[0].origin=='upper': + im.flipud_out() + im.is_grayscale = False l, b, w, h = self.bbox.bounds # composite images need special args so they will not Modified: trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py =================================================================== --- trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/backends/backend_gtkagg.py 2008-06-20 17:09:12 UTC (rev 5618) @@ -47,7 +47,7 @@ class FigureCanvasGTKAgg(FigureCanvasGTK, FigureCanvasAgg): filetypes = FigureCanvasGTK.filetypes.copy() filetypes.update(FigureCanvasAgg.filetypes) - + def configure_event(self, widget, event=None): if DEBUG: print 'FigureCanvasGTKAgg.configure_event' @@ -80,6 +80,14 @@ ren = self.get_renderer() w = int(ren.width) h = int(ren.height) + + # There apparently is a bug here on some versions of pygtk + # (2.6) that crops up in corner cases. Eg, in + # figimage_demo.py, there is background pixel noise because + # the figure frame is off and the blended image background has + # alpha 0. and you see the uninitialzed data ("screen noise"). + # If in _image.cpp Image:from_image you fill the background + # with a non transparent value, it goes away. pixbuf = gtk.gdk.pixbuf_new_from_data( buf, gtk.gdk.COLORSPACE_RGB, True, 8, w, h, w*4) pixmap.draw_pixbuf(pixmap.new_gc(), pixbuf, 0, 0, 0, 0, w, h, Modified: trunk/matplotlib/lib/matplotlib/figure.py =================================================================== --- trunk/matplotlib/lib/matplotlib/figure.py 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/lib/matplotlib/figure.py 2008-06-20 17:09:12 UTC (rev 5618) @@ -807,6 +807,9 @@ im = _image.from_images(self.bbox.height * mag, self.bbox.width * mag, ims) + if self.images[0].origin=='upper': + im.flipud_out() + im.is_grayscale = False l, b, w, h = self.bbox.bounds clippath, affine = self.get_transformed_clip_path_and_affine() Modified: trunk/matplotlib/src/_gtkagg.cpp =================================================================== --- trunk/matplotlib/src/_gtkagg.cpp 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/src/_gtkagg.cpp 2008-06-20 17:09:12 UTC (rev 5618) @@ -94,8 +94,9 @@ destrbuf.attach(destbuffer, destwidth, destheight, deststride); pixfmt destpf(destrbuf); renderer_base destrb(destpf); - //destrb.clear(agg::rgba(1, 0, 0)); + //destrb.clear(agg::rgba(1, 1, 1, 0)); + agg::rect_base<int> region(destx, desty, (int)r, srcheight-(int)b); destrb.copy_from(*aggRenderer->renderingBuffer, ®ion, -destx, -desty); Modified: trunk/matplotlib/src/_image.cpp =================================================================== --- trunk/matplotlib/src/_image.cpp 2008-06-20 15:32:40 UTC (rev 5617) +++ trunk/matplotlib/src/_image.cpp 2008-06-20 17:09:12 UTC (rev 5618) @@ -739,11 +739,14 @@ renderer_base rb(pixf); + //clear the background of the rendering buffer with alpha 1 and the + //gtkagg screen noise problem in figimage_demo.py goes away -- see + //comment backend_gtkagg.py _render_figure method JDH + //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()); - if (imnum==0) - rb.clear(thisim->bg); ox = Py::Int(tup[1]); oy = Py::Int(tup[2]); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |