diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index 47af3b4..04f31a3 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -79,6 +79,8 @@ namespace PesFile private bool formatWarning = false; + private bool classWarning = false; + //bool _readyToUse = false; public PesFile(string filename) @@ -283,15 +285,17 @@ namespace PesFile //not yet supported foundAClass = true; formatWarning = true; + classWarning = true; } if (tempstring.Contains("CGroupObject")) { //not yet supported; this seems to go with CEmbLine foundAClass = true; formatWarning = true; + classWarning = true; } - if(!foundAClass) + if (!foundAClass) { readyStatus = statusEnum.ReadError; lastError = "No headers or classes found"; @@ -495,7 +499,7 @@ namespace PesFile } if (yValue == -32765) { - int skipafew=0; + int skipafew = 0; for (int x = 0; x < 4; x++) { skipafew = file.ReadInt16(); @@ -534,7 +538,7 @@ namespace PesFile //} } - List filterStitches(List input) + List filterStitches(List input, int threshold) { List retval = new List(); List tempStitchData = new List(); @@ -543,15 +547,21 @@ namespace PesFile for (int i = 0; i < input[x].stitches.Length; i++) { - if (i > 0) + if (i > 0)//need a previous point to check against, can't check the first { - if (Math.Abs(Math.Sqrt(Math.Pow(input[x].stitches[i].X - input[x].stitches[i - 1].X, 2) + Math.Pow(input[x].stitches[i].Y - input[x].stitches[i - 1].Y, 2))) < 105) //check distance between this point and the last one + double diffx = Math.Abs(input[x].stitches[i].X - input[x].stitches[i - 1].X); + double diffy = Math.Abs(input[x].stitches[i].Y - input[x].stitches[i - 1].Y); + if (Math.Sqrt(Math.Pow(diffx, 2.0) + Math.Pow(diffy, 2.0)) < threshold) //check distance between this point and the last one { + if (tempStitchData.Count == 0 && i > 1)//first stitch of block gets left out without this, except for very first stitch + { + tempStitchData.Add(input[x].stitches[i - 1]); + } tempStitchData.Add(input[x].stitches[i]); } - else + else//stitch is too far from the previous one { - if (tempStitchData.Count > 2) + if (tempStitchData.Count > 2)//add the block and start a new one { stitchBlock tempBlock = new stitchBlock(); tempBlock.color = input[x].color; @@ -561,8 +571,16 @@ namespace PesFile retval.Add(tempBlock); tempStitchData = new List(); } + else//reset variables + { + tempStitchData = new List(); + } } } + else //just add the first one, don't have anything to compare against + { + tempStitchData.Add(input[x].stitches[i]); + } } if (tempStitchData.Count > 2) { @@ -907,6 +925,11 @@ namespace PesFile return formatWarning; } + public bool getClassWarning() + { + return classWarning; + } + private Color getColorFromIndex(int index) { Color retval;// = Color.White; @@ -1113,7 +1136,7 @@ namespace PesFile return retval; } - public Bitmap designToBitmap(Single threadThickness) + public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, int filterUglyStitchesThreshold) { Bitmap DrawArea; Graphics xGraph; @@ -1128,9 +1151,9 @@ namespace PesFile #if DEBUG tmpblocks = blocks; #else - if (!formatWarning) //only filter stitches if we think we understand the format + if (filterUglyStitches && !formatWarning) //only filter stitches if we think we understand the format { - tmpblocks = filterStitches(blocks); + tmpblocks = filterStitches(blocks, filterUglyStitchesThreshold); } else { diff --git a/PesFile/Properties/AssemblyInfo.cs b/PesFile/Properties/AssemblyInfo.cs index 3b640c7..9998a67 100644 --- a/PesFile/Properties/AssemblyInfo.cs +++ b/PesFile/Properties/AssemblyInfo.cs @@ -55,5 +55,5 @@ using System.Runtime.InteropServices; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.1.145")] -[assembly: AssemblyFileVersion("1.0.1.145")] +[assembly: AssemblyVersion("1.0.1.171")] +[assembly: AssemblyFileVersion("1.0.1.171")] diff --git a/PesFile/bin/Debug/PesFile.dll b/PesFile/bin/Debug/PesFile.dll index b2179eb..9112c1e 100644 Binary files a/PesFile/bin/Debug/PesFile.dll and b/PesFile/bin/Debug/PesFile.dll differ diff --git a/PesFile/bin/Release/PesFile.dll b/PesFile/bin/Release/PesFile.dll index 028af2e..6341500 100644 Binary files a/PesFile/bin/Release/PesFile.dll and b/PesFile/bin/Release/PesFile.dll differ