Difference between revisions of "GSD"

From Inkscape Wiki
Jump to navigation Jump to search
 
(16 intermediate revisions by 3 users not shown)
Line 2: Line 2:


== The GSD binary file format ==
== The GSD binary file format ==
This is my first try to reverse engineer a binary file format. If you like, you could add your thoughts!
The file must begin with . This is a header to verify that it is the correct file type.
By comparison between different files with the extention .gsd i try to see what data is stored where. It has some parts in ansi-text and the most parts are just binary numbers of different length. As identification, the file starts with the text "GRAPHTEC PRT&CUT". The next line at offset 0000:0010 starts with binary numbers "03 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00" (I don't know if they make any sense there).
===Header===
{|border="0" cellspacing="0" cellpadding="0" align="left"
|0x00-0x0f ||"GRAPHTEC PRT&CUT"
|-
|0x10-0x17 ||0x06 00 00 00 01 00 00 00 00
|-
|0x18-0x7f ||This entire block is padded with zeros. There may be some other information stored, but in every sample file examined the data is simply 0.
|}


* From offset 0000:0080 to offset 0000:00cf is unknown binary data.
===Body===
* From offset 0000:00d3 to offset 0000:00de is binary data, which is exactly repeated from offset 0000:00fb to 0000:0107. It starts with the hex numbers 40 6a 40 which seems to be a marker for file seek. It ends with 40 00 04. Inbetween those bytes is data which funktion is still unknown.
The body consists of a number of blocks of data. Every block starts with a length chunk indicating how many chunks are contained within that block. For more complex data such as the actual lines, polylines, and pen information chunks may contain entire blocks in a hierarchy.


* Every object can have a different color in the 8bit-RGB-color-range. E.g. RGB(254,254,254), but most probably it is only black. RGB(0,0,0). The first color is defined as ansi text from position 0000:05cd to 0000:05de.
====Chunks====
The first two bytes of the chunk provide information on the purpos. The following 2 bytes indicate the type of data and the number of data elements of that type.


* The size of the canvas is defined from 0000:0674 to 0000:067f and it ends with a big R. The value could be in upper case letters "ISO A4.....R" or "LETTER.....R" The string must be trunkated after the 11th char and a R must be appended.
While the data typically follows this pattern, in some cases (most notably distance measurements) the "datatype" may indicate a different length than is actually used.
{| border="1" cellspacing="0" cellpadding="5" align="center"
!Header !!Description
|-
|00 ||1 byte of data stored in length byte
|-
|01 ||1-byte little endian 8-bit integer. Typically used for boolean values.
|-
|02 ||2-byte little endian 16-bit integer
|-
|03 ||4-byte little endian 32-bit integer
|-
|04 ||8-byte little endian double precision float. Usually for storing a distance in mm units
|-
|05 ||ASCII data chunks
|}


* The hex value 40 seems to be the delimiter between chunks of data of different length.
Based on several files generated using version 5.10 of the QuicKutz ROBO Master software, the following information has been deduced. In some cases the data observed in a given chunk is provided where the purpose is unknown.
{| border="1" cellspacing="0" align="left"
|+Drawing Object Types:
!Value !!Type
|-
|0 ||line
|-
|1 ||polyline
|-
|4 ||elliptical arc
|-
|5 ||nurb spline
|-
|6 ||text
|-
|7 ||rectangle
|-
|9 ||rounded rectangle
|}
 
 
 
{| border="1" cellspacing="0" align="left"
|+Chunk Types
!Prefix !!Suffix !!Description !!DataType !!Data Length
|-
|03
|-
| ||01 ||Number of Drawing Objects
|-
|04
|-
| ||00 ||Drawing Object
|-
| ||01 ||Drawing Object Type
|-
| ||0A ||2D Point
|-
| ||0B ||Polyline Length
|-
| ||0C ||Polyline Point
|-
| ||14 ||Sweep (radians)
|-
| ||15 ||Ecentricity?
|-
| ||16 ||(0=Open/1=Closed)
|-
| ||40 ||Bbox (Upper Left)
|-
| ||41 ||Bbox (Upper Right)
|-
| ||42 ||Bbox (Lower Right)
|-
| ||43 ||Bbox (Lower Left)
|-
| ||44 ||Rotation
|-
|05
|-
| ||21 ||Group
|-
|07
|-
| ||02 ||Number of Line Styles? ||03 ||01
|-
| ||05 ||Dashed Line Pattern Cut Segment Length ||04 ||01 
|-
| ||06 ||Dashed Line Pattern Spacing Length ||04 ||01
|-
|08
|-
| ||01 ||Name of cutter? ||05 ||var
|-
| ||02 ||Name of cutter? ||05 ||var
|-
| ||04 ||Text description of paper type ||05 ||var
|-
| ||05 ||Paper size in 0.01mm units (Width, Height) ||03 ||02
|-
| ||08 ||Cutting Rotation Angle ||02 ||01
|-
| ||09 ||Offset Enabled ||01 ||01
|-
| ||0A ||Offset X ||03 ||01
|-
| ||0B ||Offset Y ||03 ||01
|-
| ||0C ||Weed Border Enabled ||01 ||01
|-
| ||0D ||Weed Border Distance ||03 ||01
|-
| ||0E ||Feed Media Enabled ||01 ||01
|-
| ||0F ||Feed Media Source (00-Start, 01-End) ||02 ||01
|-
| ||10 ||Feed Length ||03 ||01
|-
| ||11 ||Tiling Enabled ||01 ||01
|-
| ||14 ||Tiling Overlap ||03 ||01
|-
| ||1A ||Scaling ||02 ||01
|-
| ||1C ||Tiling Media Width ||03 ||01
|-
| ||1D ||Tiling Media Height ||03 ||01
|-
| ||21 ||Print Rotation Angle ||02 ||01
|-
| ||22 ||Print Cut Lines Enabled ||01 ||01
|-
| ||23 ||ID for print paper size? ||02 ||01
|-
| ||24 ||Paper Width in 0.1mm units ||03 ||01
|-
| ||25 ||Paper Height in 0.1mm units ||03 ||01
|-
| ||26 ||Paper Orientation (01=Portrait, 02=Landscape) ||02 ||01
|-
|0A
|-
| ||00 ||Page Style?
|-
|0B
|-
| ||00 ||Line Style?
|-
|0E
|-
| ||00 ||Registration Mark Settings
|-
| ||01 ||Show Registration Marks Enabled ||01 ||01
|-
| ||02 ||Registration Mode(00=2, 01=3, 02=4) ||02 ||01
|-
| ||03 ||Registration Pattern(01=Normal, 00=Inward) ||02 ||01
|-
| ||0A ||Registration Size
|-
| ||0B ||Registration Thickness
|-
| ||0C ||Origin X
|-
| ||0D ||Origin Y
|-
| ||0E ||Distance (1-2)
|-
| ||0F ||Distance (2-3)
|-
| ||10 ||Exceeds Maximum Recommended Length of 31.5"
|-
|0F
|-
| ||00 ||Grid Settings
|-
| ||01 ||Show Grid ||01 ||01
|-
| ||02 ||Grid Type (00=Line, 01=Dot) ||02 ||01
|-
| ||03 ||Grid Spacing ||04 ||01
|-
| ||04 ||Grid Snap Enabled ||01 ||01
|-
|10
|-
| ||00 ||End of File
|-
|}

Latest revision as of 19:47, 7 November 2009


The GSD binary file format

The file must begin with . This is a header to verify that it is the correct file type.

Header

0x00-0x0f "GRAPHTEC PRT&CUT"
0x10-0x17 0x06 00 00 00 01 00 00 00 00
0x18-0x7f This entire block is padded with zeros. There may be some other information stored, but in every sample file examined the data is simply 0.

Body

The body consists of a number of blocks of data. Every block starts with a length chunk indicating how many chunks are contained within that block. For more complex data such as the actual lines, polylines, and pen information chunks may contain entire blocks in a hierarchy.

Chunks

The first two bytes of the chunk provide information on the purpos. The following 2 bytes indicate the type of data and the number of data elements of that type.

While the data typically follows this pattern, in some cases (most notably distance measurements) the "datatype" may indicate a different length than is actually used.

Header Description
00 1 byte of data stored in length byte
01 1-byte little endian 8-bit integer. Typically used for boolean values.
02 2-byte little endian 16-bit integer
03 4-byte little endian 32-bit integer
04 8-byte little endian double precision float. Usually for storing a distance in mm units
05 ASCII data chunks

Based on several files generated using version 5.10 of the QuicKutz ROBO Master software, the following information has been deduced. In some cases the data observed in a given chunk is provided where the purpose is unknown.

Drawing Object Types:
Value Type
0 line
1 polyline
4 elliptical arc
5 nurb spline
6 text
7 rectangle
9 rounded rectangle


Chunk Types
Prefix Suffix Description DataType Data Length
03
01 Number of Drawing Objects
04
00 Drawing Object
01 Drawing Object Type
0A 2D Point
0B Polyline Length
0C Polyline Point
14 Sweep (radians)
15 Ecentricity?
16 (0=Open/1=Closed)
40 Bbox (Upper Left)
41 Bbox (Upper Right)
42 Bbox (Lower Right)
43 Bbox (Lower Left)
44 Rotation
05
21 Group
07
02 Number of Line Styles? 03 01
05 Dashed Line Pattern Cut Segment Length 04 01
06 Dashed Line Pattern Spacing Length 04 01
08
01 Name of cutter? 05 var
02 Name of cutter? 05 var
04 Text description of paper type 05 var
05 Paper size in 0.01mm units (Width, Height) 03 02
08 Cutting Rotation Angle 02 01
09 Offset Enabled 01 01
0A Offset X 03 01
0B Offset Y 03 01
0C Weed Border Enabled 01 01
0D Weed Border Distance 03 01
0E Feed Media Enabled 01 01
0F Feed Media Source (00-Start, 01-End) 02 01
10 Feed Length 03 01
11 Tiling Enabled 01 01
14 Tiling Overlap 03 01
1A Scaling 02 01
1C Tiling Media Width 03 01
1D Tiling Media Height 03 01
21 Print Rotation Angle 02 01
22 Print Cut Lines Enabled 01 01
23 ID for print paper size? 02 01
24 Paper Width in 0.1mm units 03 01
25 Paper Height in 0.1mm units 03 01
26 Paper Orientation (01=Portrait, 02=Landscape) 02 01
0A
00 Page Style?
0B
00 Line Style?
0E
00 Registration Mark Settings
01 Show Registration Marks Enabled 01 01
02 Registration Mode(00=2, 01=3, 02=4) 02 01
03 Registration Pattern(01=Normal, 00=Inward) 02 01
0A Registration Size
0B Registration Thickness
0C Origin X
0D Origin Y
0E Distance (1-2)
0F Distance (2-3)
10 Exceeds Maximum Recommended Length of 31.5"
0F
00 Grid Settings
01 Show Grid 01 01
02 Grid Type (00=Line, 01=Dot) 02 01
03 Grid Spacing 04 01
04 Grid Snap Enabled 01 01
10
00 End of File