From 58de68c924618b37dab5c9208c9233c586994267 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Andr=C3=A9=20Wobst?= Date: Sat, 6 Oct 2012 20:53:49 +0000 Subject: [PATCH] use new pipeGS functionality for bitmap based epsfile and mesh inclusion git-svn-id: https://pyx.svn.sourceforge.net/svnroot/pyx/trunk/pyx@3273 069f4177-920e-0410-937b-c2a4a81bcd90 --- pyx/epsfile.py | 7 +------ pyx/mesh.py | 16 ++++------------ 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/pyx/epsfile.py b/pyx/epsfile.py index 59d291b0..88c52aef 100644 --- a/pyx/epsfile.py +++ b/pyx/epsfile.py @@ -348,13 +348,8 @@ class epsfile(canvasitem.canvasitem): import Image c = canvas.canvas() c.insert(self) - fd, fname = tempfile.mkstemp() - f = os.fdopen(fd, "wb") - f.close() - c.pipeGS(fname, device="pngalpha", resolution=600) - i = Image.open(fname) + i = Image.open(c.pipeGS(device="pngalpha", resolution=600, seekable=True)) i.load() - os.unlink(fname) b = bitmap.bitmap_pt(self.bbox().llx_pt, self.bbox().lly_pt, i) # we slightly shift the bitmap to re-center it, as the bitmap might contain some additional border # unfortunately we need to construct another bitmap instance for that ... diff --git a/pyx/mesh.py b/pyx/mesh.py index c4a2a55c..1de20f1e 100644 --- a/pyx/mesh.py +++ b/pyx/mesh.py @@ -113,12 +113,8 @@ class mesh(canvasitem.canvasitem): import Image c = canvas.canvas() c.insert(self) - fd, fname = tempfile.mkstemp() - f = os.fdopen(fd, "wb") - f.close() - c.pipeGS(fname, device="pngalpha", resolution=writer.mesh_as_bitmap_resolution) - i = Image.open(fname) - os.unlink(fname) + i = Image.open(c.pipeGS("pngalpha", resolution=writer.mesh_as_bitmap_resolution, seekable=True)) + i.load() b = bitmap.bitmap_pt(self.bbox().llx_pt, self.bbox().lly_pt, i) # we slightly shift the bitmap to re-center it, as the bitmap might contain some additional border # unfortunately we need to construct another bitmap instance for that ... @@ -147,12 +143,8 @@ class mesh(canvasitem.canvasitem): import Image c = canvas.canvas() c.insert(self) - fd, fname = tempfile.mkstemp() - f = os.fdopen(fd, "wb") - f.close() - c.pipeGS(fname, device="pngalpha", resolution=writer.mesh_as_bitmap_resolution) - i = Image.open(fname) - os.unlink(fname) + i = Image.open(c.pipeGS("pngalpha", resolution=writer.mesh_as_bitmap_resolution, seekable=True)) + i.load() b = bitmap.bitmap_pt(self.bbox().llx_pt, self.bbox().lly_pt, i) # we slightly shift the bitmap to re-center it, as the bitmap might contain some additional border # unfortunately we need to construct another bitmap instance for that ... -- 2.11.4.GIT