diff options
Diffstat (limited to 'UVtools.Core/Operations/OperationCalibrateGrayscale.cs')
-rw-r--r-- | UVtools.Core/Operations/OperationCalibrateGrayscale.cs | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs index 4e9a015..5ddddf7 100644 --- a/UVtools.Core/Operations/OperationCalibrateGrayscale.cs +++ b/UVtools.Core/Operations/OperationCalibrateGrayscale.cs @@ -15,6 +15,7 @@ using Emgu.CV.CvEnum; using Emgu.CV.Structure; using Emgu.CV.Util; using UVtools.Core.Extensions; +using UVtools.Core.FileFormats; using UVtools.Core.Objects; namespace UVtools.Core.Operations @@ -437,6 +438,78 @@ namespace UVtools.Core.Operations return thumbnail; } + public override bool Execute(FileFormat slicerFile, OperationProgress progress = null) + { + progress ??= new OperationProgress(); + progress.Reset(ProgressAction, LayerCount); + slicerFile.SuppressRebuildProperties = true; + + var newLayers = new Layer[LayerCount]; + + slicerFile.LayerHeight = (float)LayerHeight; + slicerFile.BottomExposureTime = (float)BottomExposure; + slicerFile.ExposureTime = (float)NormalExposure; + slicerFile.BottomLayerCount = BottomLayers; + + var layers = GetLayers(); + progress++; + + + var bottomLayer = new Layer(0, layers[0], slicerFile.LayerManager) + { + IsModified = true + }; + var interfaceLayer = InterfaceLayers > 0 && layers[1] is not null ? new Layer(0, layers[1], slicerFile.LayerManager) + { + IsModified = true + } : null; + var layer = new Layer(0, layers[2], slicerFile.LayerManager) + { + IsModified = true + }; + + uint layerIndex = 0; + for (uint i = 0; i < BottomLayers; i++) + { + newLayers[layerIndex] = bottomLayer.Clone(); + progress++; + layerIndex++; + } + + for (uint i = 0; i < InterfaceLayers; i++) + { + newLayers[layerIndex] = interfaceLayer.Clone(); + progress++; + layerIndex++; + } + + + for (uint i = 0; i < NormalLayers; i++) + { + newLayers[layerIndex] = layer.Clone(); + progress++; + layerIndex++; + } + + foreach (var mat in layers) + { + mat?.Dispose(); + } + + + if (slicerFile.ThumbnailsCount > 0) + slicerFile.SetThumbnails(GetThumbnail()); + + progress++; + + + slicerFile.LayerManager.Layers = newLayers; + slicerFile.SuppressRebuildProperties = false; + slicerFile.LayerManager.RebuildLayersProperties(); + + return true; + } + #endregion } } |