pnodbnda
pnodbnda

Reputation: 31

Python + Cairo: How Do I Save a Drawing?

Suppose I create a blank area in a window and draw some lines in it, how can I save that in a .png or .jpg? Or maybe convert it to an object PIL could understand?

Upvotes: 3

Views: 3878

Answers (1)

pnodbnda
pnodbnda

Reputation: 659

Answer here: Using Pycairo to generate images dynamically and serve in Django though it only says how to save to .png.

surface = cairo.ImageSurface(cairo.FORMAT_ARGB32, 100, 100)
context = cairo.Context(surface)
# Draw something ...

surface.write_to_png('filename')

Upvotes: 6

Related Questions