forked from Embroidermodder/libembroidery
-
Notifications
You must be signed in to change notification settings - Fork 0
/
format-phc.c
44 lines (38 loc) · 1.59 KB
/
format-phc.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
/*! 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 readPhc(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
int colorChanges, version, bytesInSection2;
unsigned short pecOffset, bytesInSection, bytesInSection3;
char pecAdd;
EmbThread t;
int i;
embFile_seek(file, 0x07, SEEK_SET);
version = binaryReadByte(file) - 0x30; /* converting from ansi number */
embFile_seek(file, 0x4D, SEEK_SET);
colorChanges = binaryReadUInt16(file);
for (i = 0; i < colorChanges; i++) {
t = pecThreads[(int)binaryReadByte(file)];
embPattern_addThread(pattern, t);
}
embFile_seek(file, 0x2B, SEEK_SET);
pecAdd = binaryReadByte(file);
binaryReadUInt32(file); /* file length */
pecOffset = binaryReadUInt16(file);
embFile_seek(file, pecOffset + pecAdd, SEEK_SET);
bytesInSection = binaryReadUInt16(file);
embFile_seek(file, bytesInSection, SEEK_CUR);
bytesInSection2 = binaryReadUInt32(file);
embFile_seek(file, bytesInSection2, SEEK_CUR);
bytesInSection3 = binaryReadUInt16(file);
embFile_seek(file, bytesInSection3 + 0x12, SEEK_CUR);
readPecStitches(pattern, file, fileName);
embPattern_flipVertical(pattern);
return 1; /*TODO: finish ReadPhc */
}
/*! 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 writePhc(EmbPattern* pattern, EmbFile* file, const char* fileName)
{
return 0; /*TODO: finish writePhc */
}