0

in short, the following code can give the context:

import skia
stream = skia.DynamicMemoryWStream()
...

There are more operations done over the stream variable, but they are not important and the key thing here is I want to convert the stream to an SVG file. I have looked Python skia library documentation, however, their documentation is poorly written and I wasn't able to find out a way to do so.

Rui
  • 49
  • 1
  • 10

1 Answers1

1

I figured out how to solve it. Say you have a variable stream which is contain the data and is DynamicMemoryWStream class, then you first need to transfer the data into class FileWStream, then you use FileWStream to transfer the data into the svg file. To be more specific, do the following:

  1. create an empty svg file, say name it example.svg
  2. create stream to the file with following code
file_stream = skia.FILEWStream("example.svg")
  1. write from stream to file stream
stream.writeToStream(file_stream)
  1. Finally flush the file stream so it write all data received to the file
file_stream.flush()
Rui
  • 49
  • 1
  • 10