From 8798fcb80c7a35c4b94bb6020e122366afbd25cc Mon Sep 17 00:00:00 2001 From: Nathan Crawford Date: Mon, 4 Apr 2016 22:10:04 -0400 Subject: [PATCH] Add basic input checks for PesFile.designToBitmap() to help diagnose issue #10 --- PesFile/PesFile.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/PesFile/PesFile.cs b/PesFile/PesFile.cs index 5f2142e..ca11ef3 100644 --- a/PesFile/PesFile.cs +++ b/PesFile/PesFile.cs @@ -579,6 +579,20 @@ namespace PesFile public Bitmap designToBitmap(Single threadThickness, bool filterUglyStitches, double filterUglyStitchesThreshold, float scale) { + // Do some basic input checks + if(scale < 0.0000001f) + { + throw new ArgumentException("Scale must be > 0"); + } + if(filterUglyStitchesThreshold < 1.0) + { + throw new ArgumentException("Filter ungly stitches threshold must be at least 1.0"); + } + if(threadThickness < 0.1) + { + throw new ArgumentException("Thread thickness must be at least 0.1"); + } + int imageWidth = (int)((GetWidth() + (threadThickness * 2)) * scale); int imageHeight = (int)((GetHeight() + (threadThickness * 2)) * scale); float tempThreadThickness = threadThickness * scale;