void DoTrueWork() { try { int maxSize = Is32Bit ? 6000 * 7000 : 22000 * 22000; //on 32bit OS we have memory limit - allow Higher value on 64bit double maxRes = Math.Sqrt((maxSize / (TargetSize.Width * TargetSize.Height))); //limit res if resultimg bmp size is to big double res = Math.Min(maxRes, SelectedTool == ImageProcessor.Tool.Line2Line || SelectedTool == ImageProcessor.Tool.Dithering ? (double)Quality : 10.0); //use a fixed resolution of 10ppmm for vectorization double fres = Math.Min(maxRes, FillingQuality); Size pixelSize = new Size((int)(TargetSize.Width * res), (int)(TargetSize.Height * res)); if (res > 0) { using (Bitmap bmp = CreateTarget(pixelSize)) { GrblFile.L2LConf conf = new GrblFile.L2LConf(); conf.res = res; conf.fres = fres; conf.markSpeed = MarkSpeed; conf.travelSpeed = TravelSpeed; conf.minPower = MinPower; conf.maxPower = MaxPower; conf.lOn = LaserOn; conf.lOff = LaserOff; conf.dir = SelectedTool == ImageProcessor.Tool.Vectorize ? FillingDirection : LineDirection; conf.oX = TargetOffset.X; conf.oY = TargetOffset.Y; conf.borderSpeed = BorderSpeed; conf.pwm = (bool)Settings.GetObject("Support Hardware PWM", true); if (SelectedTool == ImageProcessor.Tool.Line2Line || SelectedTool == ImageProcessor.Tool.Dithering) { mCore.LoadedFile.LoadImageL2L(bmp, mFileName, conf, mAppend); } else if (SelectedTool == ImageProcessor.Tool.Vectorize) { mCore.LoadedFile.LoadImagePotrace(bmp, mFileName, UseSpotRemoval, (int)SpotRemoval, UseSmoothing, Smoothing, UseOptimize, Optimize, OptimizeFast, conf, mAppend); } else if (SelectedTool == ImageProcessor.Tool.Centerline) { mCore.LoadedFile.LoadImageCenterline(bmp, mFileName, UseCornerThreshold, CornerThreshold, UseLineThreshold, LineThreshold, conf, mAppend); } } if (GenerationComplete != null) { GenerationComplete(null); } } else { if (GenerationComplete != null) { GenerationComplete(new System.InvalidOperationException("Target size too big for processing!")); } } } catch (Exception ex) { if (GenerationComplete != null) { GenerationComplete(ex); } } }
void DoTrueWork() { try { int maxSize = 6000 * 7000; //testato con immagini da 600*700 con res 10ppm int maxRes = (int)Math.Sqrt((maxSize / (TargetSize.Width * TargetSize.Height))); //limit res if resultimg bmp size is to big int res = Math.Min(maxRes, SelectedTool == ImageProcessor.Tool.Line2Line || SelectedTool == ImageProcessor.Tool.Dithering ? (int)Quality : 10); //use a fixed resolution of 10ppmm int fres = Math.Min(maxRes, FillingQuality); Size pixelSize = new Size((int)(TargetSize.Width * res), (int)(TargetSize.Height * res)); if (res > 0) { using (Bitmap bmp = CreateTarget(pixelSize)) { GrblFile.L2LConf conf = new GrblFile.L2LConf(); conf.res = res; conf.fres = fres; conf.markSpeed = MarkSpeed; conf.travelSpeed = TravelSpeed; conf.minPower = MinPower; conf.maxPower = MaxPower; conf.lOn = LaserOn; conf.lOff = LaserOff; conf.dir = SelectedTool == ImageProcessor.Tool.Vectorize ? FillingDirection : LineDirection; conf.oX = TargetOffset.X; conf.oY = TargetOffset.Y; conf.borderSpeed = BorderSpeed; conf.pwm = (bool)Settings.GetObject("Support Hardware PWM", true); if (SelectedTool == ImageProcessor.Tool.Line2Line || SelectedTool == ImageProcessor.Tool.Dithering) { mCore.LoadedFile.LoadImageL2L(bmp, mFileName, conf); } else if (SelectedTool == ImageProcessor.Tool.Vectorize) { mCore.LoadedFile.LoadImagePotrace(bmp, mFileName, UseSpotRemoval, (int)SpotRemoval, UseSmoothing, Smoothing, UseOptimize, Optimize, conf); } } if (GenerationComplete != null) { GenerationComplete(null); } } else { if (GenerationComplete != null) { GenerationComplete(new System.InvalidOperationException("Target size too big for processing!")); } } } catch (Exception ex) { if (GenerationComplete != null) { GenerationComplete(ex); } } }