10from __future__
import print_function
17 sys.stderr.write(
'Usage:\n\tpython %s MSKP_FILE [OUTPUT_SKP]\n\n'
22src = open(mskp_src,
'rb')
24magic_constant = b
'Skia Multi-Picture Doc\n\n'
25magic = src.read(
len(magic_constant))
26if magic != magic_constant:
27 sys.stderr.write(
'Not a mskp file: "%s"\n' % mskp_src)
30version, page_count = struct.unpack(
'II', src.read(8))[:2]
31print(
'MSKP version: ', version)
32print(
'page count: ', page_count)
33if version > 2
or version < 1:
35 sys.stderr.write(
'unsupported mskp version\n')
38for page
in range(page_count):
39 print(
'page %3d\t' % page, end=
'')
41 offset, size_x, size_y =struct.unpack(
'Qff', src.read(16))
42 print(
'offset = %-7d\t' % offset, end=
'')
43 offsets.append(offset)
45 size_x, size_y =struct.unpack(
'ff', src.read(8))
46 print(
'size = (%r,%r)' % (size_x, size_y))
49 with open(sys.argv[2],
'wb')
as o:
50 if version == 2
or len(offsets) < 2:
52 file_buffer = src.read(8192)
53 if 0 ==
len(file_buffer):
57 o.write(src.read(offsets[1] - offsets[0]))
def print(*args, **kwargs)