diff options
Diffstat (limited to 'thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/png.py')
-rwxr-xr-x | thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/png.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/png.py b/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/png.py new file mode 100755 index 0000000..6cce422 --- /dev/null +++ b/thirdparty/cairoplot-trunk/trunk/cairoplot/handlers/png.py @@ -0,0 +1,19 @@ + +import cairo + +from .fixedsize import FixedSizeHandler as _FixedSizeHandler + +class PNGHandler(_FixedSizeHandler): + """Handler to create plots that output to png files.""" + + def __init__(self, filename, width, height): + """Creates a surface to be used by Cairo.""" + _FixedSizeHandler.__init__(self, width, height) + self.filename = filename + self.surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, width, height) + + def commit(self, plot): + """Writes plot to file.""" + _FixedSizeHandler.commit(self, plot) + self.surface.write_to_png(self.filename) + |