Page tree

 

1.     CMP Format

 

1.1     The Header

 

The CMP header contains 4 bytes.

Order ( in bytes)

Variable / Value

Description

1

-

algorithm+ version

2

X

resolution+ relative accuracy

3

Y

resolution+ Bytes per Point

4

0x90

-

Ex :

(0x10+0x01)+(68+128)+(114+128)+0x90

11 C4 F2 90

1.2     The Data

 

The Pen status is checked by using the x and y values of a point. Negative values indicate a pen up status (x = -1, y = -1). The four byte cmp header is created at start up. Compression is performed based on the pen status variations. 

 

Data compression is performed by using the scaled difference between two successive data points. X and Y coordinates are scaled down by dividing the coordinates by predefined values (XSHIFT, YSHIFT). The outcome is shifted right (once) to scale the accuracy of the coordinates. The scaled down difference between the previous point and current point coordinates are stored as delta x and delta y. The largest absolute value of the two is selected as the step size for the compression.

 

The compression is performed in two modes. Mode 0 is used for small step size (< 5) and mode 1 for large step sizes. If the step size is less than 2 then that point is neglected. The difference is encoded in to a nibble. If the step size is large the compression is switched to mode. If the step size is between 7 and 15 then compression is done in two steps by using a byte per point. For even larger step sizes a byte each is allocated for dx and dy. A flag byte is used to indicate large step bytes. Below table illustrates this.              

 

Pendown/up

0x08 / 0x09

Scaled X coordinate

Scaled Y coordinate

Nibble encoded data…

(Small step size)

Byte per point data…

Large Step Flag

large step X coordinate

large step Y coordinate

Nibble encoded data…

(Small step size)

Pen down/up

 

 

2.     SIG Format

 

SIG format is the most basic signature format. Further it is used as the input data format for most signature compression algorithms.

2.1     The Header

 

The SIG header contains 16 bytes.

 

  Order ( in bytes )

Variable / Value

Description

1,2

ID[2]

Inforite signature file identifier 'MP'.

3,4

SigOffset

Offset to start of signature data

5,6

SigSize

Number of bytes in signature data

7

Version

Version number of file. Currently 2

8

Flags

Status flags

9,10

Width

Maximum range of X values

11,12

Height

Maximum range of Y values

13,14

HorzDPI

Horizontal DPI

15,16

VertDPI

Vertical DPI

 

2.2     The Data

The SIG data is represented in stroke basis.  A new stroke takes the following form.

0x4000 ( 2 bytes) for Horizontal coordinate.

0x4000 ( 2 bytes) for Vertical coordinate.