public class Parser extends Object
Stroke
objects, which have a
list of Stroke.Point
objects.
Scribbles are stored in the annotations.data
column (see
documentation of class ScribbleMgr
for information about the structure of the database), as a binary blob with
the following structure.
The not-used parts are represented in gray (in this case the meaning is not
sure) and the bytes in the examples are represented as a couple of
hexadecimal digits. Note that the bytes are stored in a reversed order, so
that the pair of bytes "01 00" has to be read as the hex number "0001", which
corresponds to 1 (and not to 256)
The first 40 bytes are the ones related to the page data:
length | type | meaning | example |
---|---|---|---|
2 | version | 01 00 | |
4 | orientation | 00 00 00 00 | |
8 | page_pixel | 00 00 00 00 00 00 00 00 | |
2 | page_r | 00 00 | |
2 | page_g | 00 00 | |
2 | page_b | 00 00 | |
4 | ul_x | 00 00 00 00 | |
4 | ul_y | 00 00 00 00 | |
4 | lr_x | D7 04 00 00 | |
4 | lr_y | DA 06 00 00 | |
4 | int | number of strokes | A3 00 00 00 |
Only the last one is actually used, as it indicates the number of strokes in the page.
After that 40 bytes, there are the strokes.
Each stroke begin with a 24-bytes sequence, representing the properties of a
stroke, and the list of points.
The 24 bytes are strucutred according to the following schema:
length | type | meaning | example |
---|---|---|---|
4 | color | 03 00 00 00 | |
4 | float | zoom | D7 A0 89 42 |
4 | layer | 00 00 00 00 | |
4 | shape | 00 00 00 00 | |
4 | int | width | 01 00 00 00 |
4 | int | number of points | 35 00 00 00 |
Each point is represented as a 12-bytes blocks:
length | type | meaning | example |
---|---|---|---|
4 | int | x coordinate | 48 00 00 00 |
4 | int | y coordinate | 6C 00 00 00 |
4 | pressure | 00 00 00 00 |
After the sequence of points, another stroke begins (or the end of the blob is reached).
Modifier | Constructor and Description |
---|---|
private |
Parser() |
Modifier and Type | Method and Description |
---|---|
static Page |
build(byte[] blob)
Create a Page from the blob.
|
private static void |
safeSkip(ByteArrayInputStream bIn,
long l)
Skips
l bytes from the ByteArrayInputStream bIn . |
public static Page build(byte[] blob) throws IOException
Stroke
objects inside the Page
object.blob
- the blob, as taken from the SQLite database filenull
if the
blob
array is empty or null
IOException
- in an error occours while reading the blobprivate static void safeSkip(ByteArrayInputStream bIn, long l) throws IOException
l
bytes from the ByteArrayInputStream bIn
.
After skipping, check if the actually skipped bytes are exactly l
;
if not, throws an IOException (the number of bytes actually skipped is in
the IOException message).bIn
- stream from whom skip the bytesl
- number of bytes to skipIOException
- if the method skipped less than l
bytes or if
an IO error occours© 2013 andynaz - http://andynaz.altervista.org