blob: 6cce422a2ad273cf444459403c84b160144d7ff5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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)
|