diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index a9c4137..51a8ba7 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -44,6 +44,8 @@ namespace PesFile private Int64 startStitches = 0; private Point translateStart; private UInt16 pesVersion; + // Native format appears to use 0.1mm steps, for 254 steps per inch + public int NativeDPI = 254; // If set to true, this variable means we couldn't figure out some or @@ -577,6 +579,7 @@ namespace PesFile return retval; } + // When scale is 1.0, each pixel appears to be 0.1mm, or about 254 ppi public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, double filterUglyStitchesThreshold, float scale) { // Do some basic input checks diff --git a/PesFile/Properties/AssemblyInfo.cs b/PesFile/Properties/AssemblyInfo.cs index 589da68..e86800f 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.5.1.0")] -[assembly: AssemblyFileVersion("1.5.1.0")] +[assembly: AssemblyVersion("1.5.2.0")] +[assembly: AssemblyFileVersion("1.5.2.0")] diff --git a/embroideryReader/Properties/AssemblyInfo.cs b/embroideryReader/Properties/AssemblyInfo.cs index 3f9db40..fcf1651 100644 --- a/embroideryReader/Properties/AssemblyInfo.cs +++ b/embroideryReader/Properties/AssemblyInfo.cs @@ -54,5 +54,5 @@ using System.Runtime.InteropServices; // Build Number // Revision // -[assembly: AssemblyVersion("2.2.1.0")] -[assembly: AssemblyFileVersion("2.2.1.0")] +[assembly: AssemblyVersion("2.2.2.0")] +[assembly: AssemblyFileVersion("2.2.2.0")] diff --git a/embroideryReader/frmMain.cs b/embroideryReader/frmMain.cs index a516c19..0c26543 100644 --- a/embroideryReader/frmMain.cs +++ b/embroideryReader/frmMain.cs @@ -531,24 +531,23 @@ namespace embroideryReader { if (design != null) { - int xDpi = e.PageSettings.PrinterResolution.X; - int yDpi = e.PageSettings.PrinterResolution.Y; - // Basic checks on printer resolution - if(xDpi < 20 || xDpi > 10000) + // Calculate scale values for print graphics object (100 dpi seems to be the default for the printer graphics object) + double graphicsXScaleFactor = (100.0 / design.NativeDPI); + double graphicsYScaleFactor = (100.0 / design.NativeDPI); + + // Check for scale out of range + if(graphicsXScaleFactor < 0.001 || graphicsXScaleFactor > 100.0) { - throw new ArgumentOutOfRangeException("Printer X DPI claims to be '" + xDpi + "', expected range 20 - 10000"); + throw new ArgumentOutOfRangeException("Print X graphics scale is '" + graphicsXScaleFactor + "', expected range is 0.001 - 100.0"); } - if (yDpi < 20 || yDpi > 10000) + if (graphicsYScaleFactor < 0.001 || graphicsYScaleFactor > 100.0) { - throw new ArgumentOutOfRangeException("Printer Y DPI claims to be '" + yDpi + "', expected range 20 - 10000"); + throw new ArgumentOutOfRangeException("Print Y graphics scale is '" + graphicsYScaleFactor + "', expected range is 0.001 - 100.0"); } - const double inchesPerMM = 0.03937007874015748031496062992126f; - double graphicsXScaleFactor = xDpi * inchesPerMM * 0.01; - double graphicsYScaleFactor = yDpi * inchesPerMM * 0.01; - double designScaleFactor = xDpi * inchesPerMM * 0.2f; + // Set print graphics object scale and draw the image e.Graphics.ScaleTransform((float)graphicsXScaleFactor, (float)graphicsYScaleFactor); - using (Bitmap tempDrawArea = design.designToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, (float)designScaleFactor)) + using (Bitmap tempDrawArea = design.designToBitmap((float)settings.threadThickness, settings.filterStiches, settings.filterStitchesThreshold, 1.0f)) { e.Graphics.DrawImage(tempDrawArea, 30, 30); }