forked from Embroidermodder/libembroidery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-gt.c
40 lines (34 loc) · 1.38 KB
/
format-gt.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*! Reads a file with the given \a fileName and loads the data into \a pattern.
* Returns \c true if successful, otherwise returns \c false. */
static int readGt(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
embPattern_loadExternalColorFile(pattern, fileName);
embFile_seek(file, 0x200, SEEK_SET); /* TODO: review for combining code. This line appears to be the only difference from the FXY format. */
while (1) {
int stitchType = NORMAL;
int b1 = (int)binaryReadByte(file);
int b2 = (int)binaryReadByte(file);
unsigned char commandByte = binaryReadByte(file);
if (commandByte == 0x91) {
embPattern_addStitchRel(pattern, 0, 0, END, 1);
break;
}
if ((commandByte & 0x01) == 0x01)
stitchType = TRIM;
if ((commandByte & 0x02) == 0x02)
stitchType = STOP;
if ((commandByte & 0x20) == 0x20)
b1 = -b1;
if ((commandByte & 0x40) == 0x40)
b2 = -b2;
embPattern_addStitchRel(pattern, b2 / 10.0, b1 / 10.0, stitchType, 1);
}
embPattern_end(pattern);
return 1;
}
/*! Writes the data from \a pattern to a file with the given \a fileName.
* Returns \c true if successful, otherwise returns \c false. */
static int writeGt(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
return 0; /*TODO: finish writeGt */
}