View Single Post
Old 03-07-2012, 05:13 AM   #1
andyh2000
Avid reader
andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.andyh2000 ought to be getting tired of karma fortunes by now.
 
andyh2000's Avatar
 
Posts: 825
Karma: 6377682
Join Date: Apr 2009
Location: UK
Device: Samsung Galaxy Z Flip 4 / Kindle Paperwhite
jetBook Color scribble file format

Here's a Python script to create a very simple scribble file with a diagonal line from top right to bottom left. The coordinate origin on the page is at the top left - x increases across the page from left to right and y increases down the page from top to bottom. I've put a few comments in which should show what's going on.

Code:
from io import FileIO
from array import array

of=FileIO('1', 'w')

# Header
of.write(array('B', [0x0c, 0x04, 0x40, 0x06]))

# New linestring - each new linestring starts with this
of.write(array('B', [0xff, 0xff, 0xff, 0xff,     0x00]))

# 1st coord pair -   loX,  hiX,  loY,  hiY,      0x00
of.write(array('B', [0xae, 0x04, 0x00, 0x00,     0x00]))

# 2nd coord pair -   loX,  hiX,  loY,  hiY,      0x00
of.write(array('B', [0x00, 0x00, 0x32, 0x06,     0x00]))

# You can have as many coordinate pairs as you like in a linestring (>=2)
# Next linestring would start with [0xff, 0xff, 0xff, 0xff, 0x00] again

of.close()
Andrew
andyh2000 is offline   Reply With Quote