diff options
| author | Roy <roy.mail.net@gmail.com> | 2018-03-03 03:00:04 +0200 |
|---|---|---|
| committer | Roy <roy.mail.net@gmail.com> | 2018-03-03 03:00:04 +0200 |
| commit | 874760d794af99938deec7120acba26c03d420c5 (patch) | |
| tree | 9db9ec2e9c30564c2d6158b33592d2aca9a7ec0a /Software/Visual_Studio/Embroidery | |
| parent | 79ffa1774217400bd750f6a85df9f969429580c3 (diff) | |
| download | Tango-874760d794af99938deec7120acba26c03d420c5.tar.gz Tango-874760d794af99938deec7120acba26c03d420c5.zip | |
Managed to get Embroidery Adapter to integrate.
Diffstat (limited to 'Software/Visual_Studio/Embroidery')
| -rw-r--r-- | Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp | 64 | ||||
| -rw-r--r-- | Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp | 26 |
2 files changed, 60 insertions, 30 deletions
diff --git a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp index 779e73b1d..55eba8a93 100644 --- a/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp +++ b/Software/Visual_Studio/Embroidery/Tango.Embroidery/Adapter.cpp @@ -10,12 +10,12 @@ -Adapter::Adapter() +Adapter::Adapter() { } -Adapter::~Adapter() +Adapter::~Adapter() { } @@ -25,7 +25,8 @@ size_t Adapter::AnalyzeEmbroideryFile(uint8_t * input_buffer, size_t input_buffe AnalyzeInput *input = analyze_input__unpack(NULL, input_buffer_size, input_buffer); //Initialize Output... - AnalyzeOutput output = ANALYZE_OUTPUT__INIT; + AnalyzeOutput* output = (AnalyzeOutput*)malloc(sizeof(AnalyzeOutput)); + analyze_output__init(output); EmbPattern* p = embPattern_create(); @@ -36,42 +37,59 @@ size_t Adapter::AnalyzeEmbroideryFile(uint8_t * input_buffer, size_t input_buffe int stitchCount = embStitchList_count(p->stitchList); int colorCount = embThreadList_count(p->threadList); - EmbroideryFile embroideryFile; + EmbroideryFile* embroideryFile = (EmbroideryFile*)malloc(sizeof(EmbroideryFile)); + embroidery_file__init(embroideryFile); - embroideryFile.colorcount = colorCount; - embroideryFile.stitchcount = stitchCount; + embroideryFile->colorcount = colorCount; + embroideryFile->has_colorcount = true; + embroideryFile->n_colors = colorCount; + embroideryFile->stitchcount = stitchCount; + embroideryFile->has_stitchcount = true; + embroideryFile->n_stitches = stitchCount; - embroideryFile.colors = (StitchColor**)malloc(sizeof(StitchColor*) * colorCount); - embroideryFile.stitches = (Stitch**)malloc(sizeof(Stitch*) * stitchCount); + embroideryFile->colors = (StitchColor**)malloc(sizeof(StitchColor*) * colorCount); + embroideryFile->stitches = (Stitch**)malloc(sizeof(Stitch*) * stitchCount); for (size_t i = 0; i < colorCount; i++) { - StitchColor color; - color.red = (int)p->threadList[i].thread.color.r; - color.green = (int)p->threadList[i].thread.color.g; - color.blue = (int)p->threadList[i].thread.color.b; + StitchColor* color = (StitchColor*)malloc(sizeof(StitchColor)); + stitch_color__init(color); - embroideryFile.colors[i] = &color; + EmbThread t = embThreadList_getAt(p->threadList, i); + + color->red = (int)t.color.r; + color->has_red = true; + color->green = (int)t.color.g; + color->has_green = true; + color->blue = (int)t.color.b; + color->has_blue = true; + + embroideryFile->colors[i] = color; } for (size_t i = 0; i < stitchCount; i++) { - EmbStitch intStitch = p->stitchList[i].stitch; + EmbStitch intStitch = embStitchList_getAt(p->stitchList, i); - Stitch outStitch; - outStitch.xx = intStitch.xx; - outStitch.yy = intStitch.yy; - outStitch.flag = (StitchFlag)intStitch.flags; - outStitch.colorindex = intStitch.color; + Stitch* outStitch = (Stitch*)malloc(sizeof(Stitch)); + stitch__init(outStitch); + outStitch->xx = intStitch.xx; + outStitch->has_xx = true; + outStitch->yy = intStitch.yy; + outStitch->has_yy = true; + outStitch->flag = (StitchFlag)intStitch.flags; + outStitch->has_flag = true; + outStitch->colorindex = intStitch.color; + outStitch->has_colorindex = true; - embroideryFile.stitches[i] = &outStitch; + embroideryFile->stitches[i] = outStitch; } - output.embroideryfile = &embroideryFile; + output->embroideryfile = embroideryFile; } //Pack output... - output_buffer = (uint8_t*)malloc(analyze_output__get_packed_size(&output)); + output_buffer = (uint8_t*)malloc(analyze_output__get_packed_size(output)); - return analyze_output__pack(&output, output_buffer); + return analyze_output__pack(output, output_buffer); } diff --git a/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp index 64c581400..e9c90ebda 100644 --- a/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp +++ b/Software/Visual_Studio/Embroidery/libEmbroideryTest/libEmbroideryTest.cpp @@ -12,7 +12,7 @@ int main() { EmbPattern* p = embPattern_create(); - int ok = embPattern_read(p, "C:\\Tests\\Blueangel.pes"); + int ok = embPattern_read(p, "C:\\Users\\Roy\\Desktop\\RGB_Strips.pes"); if (ok) { @@ -25,15 +25,27 @@ int main() for (size_t i = 0; i < t_count; i++) { - cout << "R: " << (int)p->threadList[i].thread.color.r << ", "; - cout << "G: " << (int)p->threadList[i].thread.color.g << ", "; - cout << "B: " << (int)p->threadList[i].thread.color.b << endl; + EmbThread t = embThreadList_getAt(p->threadList, i); + + cout << "R: " << (int)t.color.r << ", "; + cout << "G: " << (int)t.color.g << ", "; + cout << "B: " << (int)t.color.b << endl; } - for (size_t i = 0; i < 100; i++) + EmbStitchList* sList = p->stitchList; + + //while (sList) + //{ + // EmbStitch s = sList->stitch; + // //cout << " X: " << setprecision(3) << s.xx << " Y: " << setprecision(3) << s.yy << " Color Index: " << s.color << endl; + + // printf("\"%f\",\"%f\"\n", s.xx, s.yy); + // sList = sList->next; + //} + + for (size_t i = 0; i < 1000; i++) { - - EmbStitch stitch = p->stitchList[i].stitch; + EmbStitch stitch = embStitchList_getAt(p->stitchList, i); cout << i << " X: " << setprecision(3) << stitch.xx << " Y: " << setprecision(3) << stitch.yy << " Color Index: " << stitch.color << endl; } } |
