forked from Embroidermodder/libembroidery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-sst.c
43 lines (36 loc) · 1.43 KB
/
format-sst.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
40
41
42
/*! 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 readSst(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
int fileLength;
embPattern_loadExternalColorFile(pattern, fileName);
embFile_seek(file, 0, SEEK_END);
fileLength = embFile_tell(file);
embFile_seek(file, 0xA0, SEEK_SET); /* skip the all zero header */
while (embFile_tell(file) < fileLength) {
int stitchType = NORMAL;
int b1 = (int)binaryReadByte(file);
int b2 = (int)binaryReadByte(file);
unsigned char commandByte = binaryReadByte(file);
if (commandByte == 0x04) {
embPattern_addStitchRel(pattern, 0, 0, END, 1);
break;
}
if ((commandByte & 0x01) == 0x01)
stitchType = STOP;
if ((commandByte & 0x02) == 0x02)
stitchType = JUMP;
if ((commandByte & 0x10) != 0x10)
b2 = -b2;
if ((commandByte & 0x40) == 0x40)
b1 = -b1;
embPattern_addStitchRel(pattern, b1 / 10.0, b2 / 10.0, stitchType, 1);
}
return 1; /*TODO: finish readSst */
}
/*! 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 writeSst(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
return 0; /*TODO: finish writeSst */
}