EmbroidePy / pyembroidery

pyembroidery library for reading and writing a variety of embroidery formats.
MIT License
181 stars 33 forks source link

PES Initial Stitch Codes #132

Open tatarize opened 2 years ago

tatarize commented 2 years ago

The PES stitches actually start at PEC_START + 128. The first one appeared to be 0x9000 for width and height but these are long jump stitches. But, with how they are currently implemented this value can, in error be 0xFFFE which is actually END causing the pes file to file as it ended before it started.

It is also possible that older read codes would have one short form and 1 long form stitch which would cause a desync of the x,y values reading the file incorrectly.

tatarize commented 2 years ago

Corrected in 1.4.32

tatarize commented 2 years ago

@kaalleen @AndyLV, this should be fixed for the inkstitch/pyembroidery version as well. It will in a number of cases write a faulty PES file based on a faulty original understanding of the file format. If have an extent of -2 for either the x or y value, which is easy to do, you end up encoding 0xFFFE as the value there which actually coincides with the END command. Wilcom V4 will not parse this file. In rare cases it can also flag a value to appear as short/long for the two bytes which can then desync the x and y which will create a scribble-file with fairly random coordinates.


https://github.com/EmbroidePy/pyembroidery/commit/2bcbfffe1b338e65741b6064cad3c44fa5cd8ddd https://github.com/EmbroidePy/pyembroidery/commit/7a53628bfa87d2f608600fb28f99f3c6ca50bb50 https://github.com/EmbroidePy/pyembroidery/commit/e81d92504711a31ca542883ba605871826a71200

Also see: Embroidermodder/libembroidery#116

tatarize commented 2 years ago

@fabricocouto, @lexelby inkstitch/pyembroidery#91

Fabricocouto's understanding of embroidery file formats is top notch. He actually codes these things and his comments should be accepted as based on valid understandings. In this case it's a bug corrected in 1.4.32. The libembroidery code in this regard was wrong and fabrico pointed out some PES files in the wild that had a non-jump first stitch which very much did cause a number of problems. Also, the writer is flawed. This error is, as far as I know, one of the worst and most needing correcting.