forked from Embroidermodder/libembroidery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-dsz.c
51 lines (44 loc) · 1.42 KB
/
format-dsz.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
43
44
45
46
47
48
49
50
/*! 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 readDsz(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
embPattern_loadExternalColorFile(pattern, fileName);
embFile_seek(file, 0x200, SEEK_SET);
while (1) {
int x, y;
unsigned char ctrl;
int stitchType = NORMAL;
y = embFile_getc(file);
if (embFile_eof(file))
break;
x = embFile_getc(file);
if (embFile_eof(file))
break;
ctrl = (unsigned char)embFile_getc(file);
if (embFile_eof(file))
break;
if (ctrl & 0x01)
stitchType = TRIM;
if (ctrl & 0x20)
y = -y;
if (ctrl & 0x40)
x = -x;
if (ctrl & 0x0E) {
int headNumber = (ctrl & 0x0E) >> 1;
stitchType = STOP;
}
if (ctrl & 0x10) {
embPattern_addStitchRel(pattern, 0, 0, END, 1);
break;
}
embPattern_addStitchRel(pattern, x / 10.0, y / 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 writeDsz(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
return 0; /*TODO: finish writeDsz */
}