Source

vanhoek / vanhoek / backends / png_writer.py

import cairo
from .backend_base import BackendBase

class PNGWriter(BackendBase):
    def __init__(self, format_string = "slide_%04i.png"):
        self.format_string = format_string

    def draw(self, slide, i):
        surface = BackendBase.draw(self, slide, i)
        surface.write_to_png(self.format_string % i)

    @property
    def surface(self):
        return cairo.ImageSurface(cairo.FORMAT_ARGB32, 1024, 768)