Article # 597, added by Geoworks, historical record
| first |
previous |
index |
next |
last |
Directly accessing CIF_INK on the clipboard.
This information is only pertinant to devices that allow pen input. Ink Format ========== Ink on the clipboard is stored as a DBGroupAndItem. CIFI_vmChain (which is the same as CRA_data) contains the DBGroupAndItem for the ink item. (Thus you can do myPtr = DBLock( cra->CRA_file, DBGroupFromDBGroupAndItem( cra->CRA_data ), DBItemFromDBGroupAndItem( cra->CRA_data ) ); to get a pointer to the ink data.) The item of ink is stored in compressed format. For which the format is: XYSize (dword) - size of the area clipped by user PointBlockHeader (word) - number of points in the ink compacted data (as bits) Here's the format of the compacted data: When compacting: Output X delta first, then Y delta. The first X and Y values you output must be an absolute 15-bit position. if (delta == 0) Output (00) else if (delta == 1) Output (01) else if (delta == -1) Output (11) else if (delta >= -8 && delta < -1) /* Output 3-bit negative delta */ Output (1001000 | (ABS(delta) - 1)) else if (delta <= 8 && delta > 1) /* Output 3-bit positive delta */ Output (1000000 | (delta - 1)) else /* Output 15-bit absolute position) */ Output (1011 0000 0000 0000 000 | delta); At the end of each segment, output (1000000) (note, this is 7 bits, not 8). When uncompacting: If you encounter: it means: 00 a delta of zero 01 a delta of 1 11 a delta of -1 100 0 000 Terminate the current segment 100 0 xxx the xxx bits are a positive (delta - 1). e.g.: 100 0001 = 2 100 0010 = 3 100 0011 = 4 100 0100 = 5 100 0101 = 6 100 0110 = 7 100 0111 = 8 100 1 000 reserved for future use 100 1 xxx the xxx bits are a negative (delta - 1). e.g.: 100 1001 = -2 100 1010 = -3 100 1011 = -4 100 1100 = -5 100 1101 = -6 100 1110 = -7 100 1111 = -8 101 0 xxxxxx the x bits are a reserved keyword - not currently used 101 1 xxxx xxxx xxxx xxx the x bits are an absolute position, not a delta You will always encounter a 1011 token (an absolute position) before encountering any deltas. Here is an example of the compressed ink data for the number '4'. And to ellucidate, here is a picture of what the 4 looks like (note the two coordinates are given to help orient you). *--(3,0) (0,1)--* * ***** * * First line drawn is the "side-ways L" part. It goes down from 0,1 and cuts right to 4,2. The second line is the main vertical. It starts at 3,0 and goes down to 3,4. Thus the data in the clipboard is: XYSize = 6,6 (6x6 is just an arbitrary number) numPoints = 5 (there are 5 coordinate points) data = 101 1 0000 0000 0000 000 (initial X) 101 1 0000 0000 0000 001 (initial Y) 00 (X no delta) 01 (Y delta 1) 100 0011 (X delta 4) 00 (Y no delta) 100 0000 (end of first segment) 101 1 0000 0000 0000 011 (initial X) 101 1 0000 0000 0000 000 (initial Y) 00 (X no delta) 100 0011 (Y delta 4) 100 0000 (end of second segment)