diff --git a/CHANGELOG.md b/CHANGELOG.md
index cadca86..952b580 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -30,6 +30,7 @@ Less frequently used settings for gap and noise removal iterations have been mov
* (Fix) Tool - Change resolution: Confirmation text was set to remove layers
* (Fix) Fade iteration now working as expected on some mutators
* (Fix) Pattern: When select big margins and cols/rows it triggers an error because value hits the maximum variable size
+* (Fix) Mask: A crash when check "Invert" when mask is not loaded
* (Fix) Some text and phrases
## 04/08/2020 - v0.7.0.0
diff --git a/UVtools.Core/Layer/Layer.cs b/UVtools.Core/Layer/Layer.cs
index eb55e8a..9e68056 100644
--- a/UVtools.Core/Layer/Layer.cs
+++ b/UVtools.Core/Layer/Layer.cs
@@ -571,7 +571,9 @@ namespace UVtools.Core
}
}
- public void MutateMask(Mat mask)
+ public void Mask(OperationMask mask) => Mask(mask.Mask);
+
+ public void Mask(Mat mask)
{
using (var mat = LayerMat)
{
diff --git a/UVtools.Core/Layer/LayerManager.cs b/UVtools.Core/Layer/LayerManager.cs
index 9968f17..871fa2d 100644
--- a/UVtools.Core/Layer/LayerManager.cs
+++ b/UVtools.Core/Layer/LayerManager.cs
@@ -401,15 +401,15 @@ namespace UVtools.Core
progress.Token.ThrowIfCancellationRequested();
}
- public void MutateMask(uint startLayerIndex, uint endLayerIndex, Mat mask, OperationProgress progress = null)
+ public void Mask(OperationMask operation, OperationProgress progress = null)
{
if (ReferenceEquals(progress, null)) progress = new OperationProgress();
- progress.Reset("Masking pixels", endLayerIndex - startLayerIndex + 1);
+ progress.Reset(operation.ProgressAction, operation.LayerRangeCount);
- Parallel.For(startLayerIndex, endLayerIndex + 1, layerIndex =>
+ Parallel.For(operation.LayerIndexStart, operation.LayerIndexEnd + 1, layerIndex =>
{
if (progress.Token.IsCancellationRequested) return;
- this[layerIndex].MutateMask(mask);
+ this[layerIndex].Mask(operation);
lock (progress.Mutex)
{
progress++;
diff --git a/UVtools.Core/Operations/OperationMask.cs b/UVtools.Core/Operations/OperationMask.cs
new file mode 100644
index 0000000..d921a1d
--- /dev/null
+++ b/UVtools.Core/Operations/OperationMask.cs
@@ -0,0 +1,46 @@
+/*
+ * GNU AFFERO GENERAL PUBLIC LICENSE
+ * Version 3, 19 November 2007
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ * Everyone is permitted to copy and distribute verbatim copies
+ * of this license document, but changing it is not allowed.
+ */
+
+using System.Text;
+using Emgu.CV;
+using Emgu.CV.CvEnum;
+using UVtools.Core.Objects;
+
+namespace UVtools.Core.Operations
+{
+ public class OperationMask : Operation
+ {
+ public override string Title => "Mask";
+ public override string Description =>
+ "Masks the LCD output image given a greyscale (0-255) pixel input image.\n" +
+ "Useful to correct light uniformity, but a proper mask must be created first based on real measurements per printer.\n" +
+ "NOTE 1: Masks should respect printer resolution or they will be resized to fit.\n" +
+ "NOTE 2: Run only this tool after all repairs and other transformations.";
+
+ public override string ConfirmationText =>
+ $"mask layers from {LayerIndexStart} to {LayerIndexEnd}";
+
+ public override string ProgressTitle =>
+ $"Masking layers from {LayerIndexStart} to {LayerIndexEnd}";
+
+ public override string ProgressAction => "Masked layers";
+
+ public override StringTag Validate(params object[] parameters)
+ {
+ var sb = new StringBuilder();
+ if (Mask is null)
+ {
+ sb.AppendLine("The mask can't be empty.");
+ }
+
+ return new StringTag(sb.ToString());
+ }
+
+ public Mat Mask { get; set; }
+ }
+}
diff --git a/UVtools.GUI/Controls/Tools/CtrlToolMask.Designer.cs b/UVtools.GUI/Controls/Tools/CtrlToolMask.Designer.cs
new file mode 100644
index 0000000..c5ea3cf
--- /dev/null
+++ b/UVtools.GUI/Controls/Tools/CtrlToolMask.Designer.cs
@@ -0,0 +1,270 @@
+namespace UVtools.GUI.Controls.Tools
+{
+ partial class CtrlToolMask
+ {
+ ///
+ /// Required designer variable.
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// Clean up any resources being used.
+ ///
+ /// true if managed resources should be disposed; otherwise, false.
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region Component Designer generated code
+
+ ///
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ ///
+ private void InitializeComponent()
+ {
+ this.groupBox2 = new System.Windows.Forms.GroupBox();
+ this.btnMaskGenerate = new System.Windows.Forms.Button();
+ this.label4 = new System.Windows.Forms.Label();
+ this.nmGeneratorDiameter = new System.Windows.Forms.NumericUpDown();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.nmGeneratorMaxBrightness = new System.Windows.Forms.NumericUpDown();
+ this.label1 = new System.Windows.Forms.Label();
+ this.nmGeneratorMinBrightness = new System.Windows.Forms.NumericUpDown();
+ this.cbInvertMask = new System.Windows.Forms.CheckBox();
+ this.lbMaskResolution = new System.Windows.Forms.Label();
+ this.lbPrinterResolution = new System.Windows.Forms.Label();
+ this.groupBox1 = new System.Windows.Forms.GroupBox();
+ this.pbMask = new System.Windows.Forms.PictureBox();
+ this.btnImportImageMask = new System.Windows.Forms.Button();
+ this.groupBox2.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).BeginInit();
+ this.groupBox1.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.pbMask)).BeginInit();
+ this.SuspendLayout();
+ //
+ // groupBox2
+ //
+ this.groupBox2.Controls.Add(this.btnMaskGenerate);
+ this.groupBox2.Controls.Add(this.label4);
+ this.groupBox2.Controls.Add(this.nmGeneratorDiameter);
+ this.groupBox2.Controls.Add(this.label3);
+ this.groupBox2.Controls.Add(this.label2);
+ this.groupBox2.Controls.Add(this.nmGeneratorMaxBrightness);
+ this.groupBox2.Controls.Add(this.label1);
+ this.groupBox2.Controls.Add(this.nmGeneratorMinBrightness);
+ this.groupBox2.Location = new System.Drawing.Point(3, 41);
+ this.groupBox2.Name = "groupBox2";
+ this.groupBox2.Size = new System.Drawing.Size(564, 96);
+ this.groupBox2.TabIndex = 42;
+ this.groupBox2.TabStop = false;
+ this.groupBox2.Text = "Mask Generator (Round from center)";
+ //
+ // btnMaskGenerate
+ //
+ this.btnMaskGenerate.Location = new System.Drawing.Point(259, 57);
+ this.btnMaskGenerate.Name = "btnMaskGenerate";
+ this.btnMaskGenerate.Size = new System.Drawing.Size(299, 26);
+ this.btnMaskGenerate.TabIndex = 41;
+ this.btnMaskGenerate.Text = "Generate";
+ this.btnMaskGenerate.UseVisualStyleBackColor = true;
+ this.btnMaskGenerate.Click += new System.EventHandler(this.EventClick);
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(6, 60);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(137, 20);
+ this.label4.TabIndex = 40;
+ this.label4.Text = "Diameter in pixels:";
+ //
+ // nmGeneratorDiameter
+ //
+ this.nmGeneratorDiameter.Location = new System.Drawing.Point(166, 57);
+ this.nmGeneratorDiameter.Maximum = new decimal(new int[] {
+ 10000,
+ 0,
+ 0,
+ 0});
+ this.nmGeneratorDiameter.Name = "nmGeneratorDiameter";
+ this.nmGeneratorDiameter.Size = new System.Drawing.Size(78, 26);
+ this.nmGeneratorDiameter.TabIndex = 39;
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(255, 28);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(60, 20);
+ this.label3.TabIndex = 38;
+ this.label3.Text = "(0-255)";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(320, 28);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(158, 20);
+ this.label2.TabIndex = 37;
+ this.label2.Text = "Maximum brightness:";
+ //
+ // nmGeneratorMaxBrightness
+ //
+ this.nmGeneratorMaxBrightness.Location = new System.Drawing.Point(480, 25);
+ this.nmGeneratorMaxBrightness.Maximum = new decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+ this.nmGeneratorMaxBrightness.Name = "nmGeneratorMaxBrightness";
+ this.nmGeneratorMaxBrightness.Size = new System.Drawing.Size(78, 26);
+ this.nmGeneratorMaxBrightness.TabIndex = 36;
+ this.nmGeneratorMaxBrightness.Value = new decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(6, 28);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(154, 20);
+ this.label1.TabIndex = 35;
+ this.label1.Text = "Minimum brightness:";
+ //
+ // nmGeneratorMinBrightness
+ //
+ this.nmGeneratorMinBrightness.Location = new System.Drawing.Point(166, 25);
+ this.nmGeneratorMinBrightness.Maximum = new decimal(new int[] {
+ 255,
+ 0,
+ 0,
+ 0});
+ this.nmGeneratorMinBrightness.Name = "nmGeneratorMinBrightness";
+ this.nmGeneratorMinBrightness.Size = new System.Drawing.Size(78, 26);
+ this.nmGeneratorMinBrightness.TabIndex = 0;
+ this.nmGeneratorMinBrightness.Value = new decimal(new int[] {
+ 200,
+ 0,
+ 0,
+ 0});
+ //
+ // cbInvertMask
+ //
+ this.cbInvertMask.AutoSize = true;
+ this.cbInvertMask.Enabled = false;
+ this.cbInvertMask.Location = new System.Drawing.Point(432, 8);
+ this.cbInvertMask.Name = "cbInvertMask";
+ this.cbInvertMask.Size = new System.Drawing.Size(110, 24);
+ this.cbInvertMask.TabIndex = 41;
+ this.cbInvertMask.Text = "Invert Mask";
+ this.cbInvertMask.UseVisualStyleBackColor = true;
+ this.cbInvertMask.CheckedChanged += new System.EventHandler(this.EventClick);
+ //
+ // lbMaskResolution
+ //
+ this.lbMaskResolution.AutoSize = true;
+ this.lbMaskResolution.Location = new System.Drawing.Point(-1, 174);
+ this.lbMaskResolution.Name = "lbMaskResolution";
+ this.lbMaskResolution.Size = new System.Drawing.Size(207, 20);
+ this.lbMaskResolution.TabIndex = 40;
+ this.lbMaskResolution.Text = "Mask resolution: (Unloaded)";
+ //
+ // lbPrinterResolution
+ //
+ this.lbPrinterResolution.AutoSize = true;
+ this.lbPrinterResolution.Location = new System.Drawing.Point(-1, 144);
+ this.lbPrinterResolution.Name = "lbPrinterResolution";
+ this.lbPrinterResolution.Size = new System.Drawing.Size(136, 20);
+ this.lbPrinterResolution.TabIndex = 39;
+ this.lbPrinterResolution.Text = "Printer resolution: ";
+ //
+ // groupBox1
+ //
+ this.groupBox1.Controls.Add(this.pbMask);
+ this.groupBox1.Location = new System.Drawing.Point(0, 209);
+ this.groupBox1.Name = "groupBox1";
+ this.groupBox1.Size = new System.Drawing.Size(567, 335);
+ this.groupBox1.TabIndex = 38;
+ this.groupBox1.TabStop = false;
+ this.groupBox1.Text = "Mask image";
+ //
+ // pbMask
+ //
+ this.pbMask.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.pbMask.Location = new System.Drawing.Point(3, 22);
+ this.pbMask.Name = "pbMask";
+ this.pbMask.Size = new System.Drawing.Size(561, 310);
+ this.pbMask.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
+ this.pbMask.TabIndex = 0;
+ this.pbMask.TabStop = false;
+ //
+ // btnImportImageMask
+ //
+ this.btnImportImageMask.Location = new System.Drawing.Point(3, 3);
+ this.btnImportImageMask.Name = "btnImportImageMask";
+ this.btnImportImageMask.Size = new System.Drawing.Size(417, 32);
+ this.btnImportImageMask.TabIndex = 37;
+ this.btnImportImageMask.Text = "Import grayscale mask image from file";
+ this.btnImportImageMask.UseVisualStyleBackColor = true;
+ this.btnImportImageMask.Click += new System.EventHandler(this.EventClick);
+ //
+ // CtrlToolMask
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.AutoSize = true;
+ this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
+ this.ButtonOkEnabled = false;
+ this.Controls.Add(this.groupBox2);
+ this.Controls.Add(this.cbInvertMask);
+ this.Controls.Add(this.lbMaskResolution);
+ this.Controls.Add(this.lbPrinterResolution);
+ this.Controls.Add(this.groupBox1);
+ this.Controls.Add(this.btnImportImageMask);
+ this.Description = "";
+ this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.Name = "CtrlToolMask";
+ this.Size = new System.Drawing.Size(570, 547);
+ this.groupBox2.ResumeLayout(false);
+ this.groupBox2.PerformLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).EndInit();
+ this.groupBox1.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.pbMask)).EndInit();
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.GroupBox groupBox2;
+ private System.Windows.Forms.Button btnMaskGenerate;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.NumericUpDown nmGeneratorDiameter;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.NumericUpDown nmGeneratorMaxBrightness;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.NumericUpDown nmGeneratorMinBrightness;
+ private System.Windows.Forms.CheckBox cbInvertMask;
+ private System.Windows.Forms.Label lbMaskResolution;
+ private System.Windows.Forms.Label lbPrinterResolution;
+ private System.Windows.Forms.GroupBox groupBox1;
+ private System.Windows.Forms.PictureBox pbMask;
+ private System.Windows.Forms.Button btnImportImageMask;
+ }
+}
diff --git a/UVtools.GUI/Controls/Tools/CtrlToolMask.cs b/UVtools.GUI/Controls/Tools/CtrlToolMask.cs
new file mode 100644
index 0000000..d5d8499
--- /dev/null
+++ b/UVtools.GUI/Controls/Tools/CtrlToolMask.cs
@@ -0,0 +1,110 @@
+/*
+ * GNU AFFERO GENERAL PUBLIC LICENSE
+ * Version 3, 19 November 2007
+ * Copyright (C) 2007 Free Software Foundation, Inc.
+ * Everyone is permitted to copy and distribute verbatim copies
+ * of this license document, but changing it is not allowed.
+ */
+
+using System;
+using System.Drawing;
+using System.Windows.Forms;
+using Emgu.CV;
+using Emgu.CV.CvEnum;
+using Emgu.CV.Structure;
+using UVtools.Core.Extensions;
+using UVtools.Core.Operations;
+using UVtools.GUI.Extensions;
+
+namespace UVtools.GUI.Controls.Tools
+{
+ public partial class CtrlToolMask : CtrlToolWindowContent
+ {
+ public OperationMask Operation { get; }
+
+ public CtrlToolMask()
+ {
+ InitializeComponent();
+ Operation = new OperationMask();
+ SetOperation(Operation);
+ lbPrinterResolution.Text = $"Printer Resolution: {Program.FrmMain.ActualLayerImage.Size}";
+ }
+
+ private void EventClick(object sender, EventArgs e)
+ {
+ if (ReferenceEquals(sender, btnImportImageMask))
+ {
+ using (var fileOpen = new OpenFileDialog
+ {
+ CheckFileExists = true,
+ Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF"
+ })
+ {
+ if (fileOpen.ShowDialog() != DialogResult.OK) return;
+
+ Operation.Mask = CvInvoke.Imread(fileOpen.FileName, ImreadModes.Grayscale);
+
+ if (Operation.Mask.Size != Program.FrmMain.ActualLayerImage.Size)
+ {
+ CvInvoke.Resize(Operation.Mask, Operation.Mask, Program.FrmMain.ActualLayerImage.Size);
+ }
+
+ if (cbInvertMask.Checked)
+ {
+ CvInvoke.BitwiseNot(Operation.Mask, Operation.Mask);
+ }
+
+ lbMaskResolution.Text = $"Mask Resolution: {Operation.Mask.Size}";
+
+ pbMask.Image = Operation.Mask.ToBitmap();
+ cbInvertMask.Enabled =
+ ButtonOkEnabled = true;
+ }
+ return;
+ }
+
+ if (ReferenceEquals(sender, cbInvertMask))
+ {
+ CvInvoke.BitwiseNot(Operation.Mask, Operation.Mask);
+ pbMask.Image = Operation.Mask.ToBitmap();
+ return;
+ }
+
+ if (ReferenceEquals(sender, btnMaskGenerate))
+ {
+ Operation.Mask = Program.FrmMain.ActualLayerImage.CloneBlank();
+ lbMaskResolution.Text = $"Mask Resolution: {Operation.Mask.Size}";
+
+ int radius = (int)nmGeneratorDiameter.Value;
+ if (radius == 0)
+ {
+ radius = Math.Min(Operation.Mask.Width, Operation.Mask.Height) / 2;
+ }
+ else
+ {
+ radius = radius.Clamp(2, Math.Min(Operation.Mask.Width, Operation.Mask.Height)) / 2;
+ }
+
+ var maxScalar = new MCvScalar((double)nmGeneratorMaxBrightness.Value);
+ Operation.Mask.SetTo(maxScalar);
+
+ var center = new Point(Operation.Mask.Width / 2, Operation.Mask.Height / 2);
+ var colorDifference = nmGeneratorMinBrightness.Value - nmGeneratorMaxBrightness.Value;
+ //CvInvoke.Circle(Mask, center, radius, minScalar, -1);
+
+ for (decimal i = 1; i < radius; i++)
+ {
+ int color = (int)(nmGeneratorMinBrightness.Value - i / radius * colorDifference); //or some another color calculation
+ CvInvoke.Circle(Operation.Mask, center, (int)i, new MCvScalar(color), 2);
+ }
+
+ if (cbInvertMask.Checked)
+ CvInvoke.BitwiseNot(Operation.Mask, Operation.Mask);
+ pbMask.Image = Operation.Mask.ToBitmap();
+ cbInvertMask.Enabled =
+ ButtonOkEnabled = true;
+ return;
+ }
+ }
+ }
+}
diff --git a/UVtools.GUI/Forms/FrmMutationMask.resx b/UVtools.GUI/Controls/Tools/CtrlToolMask.resx
similarity index 92%
rename from UVtools.GUI/Forms/FrmMutationMask.resx
rename to UVtools.GUI/Controls/Tools/CtrlToolMask.resx
index ceac7ae..8766f29 100644
--- a/UVtools.GUI/Forms/FrmMutationMask.resx
+++ b/UVtools.GUI/Controls/Tools/CtrlToolMask.resx
@@ -118,14 +118,6 @@
System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
- 148, 17
-
-
- Selects the layers range within start layer and end layer where mutator will operate.
-Select same layer start as end to operate only within that layer.
-Note: "Layer Start" start can't be higher than "Layer End".
-
-
17, 17
\ No newline at end of file
diff --git a/UVtools.GUI/Forms/FrmMutationMask.Designer.cs b/UVtools.GUI/Forms/FrmMutationMask.Designer.cs
deleted file mode 100644
index 6e3a476..0000000
--- a/UVtools.GUI/Forms/FrmMutationMask.Designer.cs
+++ /dev/null
@@ -1,475 +0,0 @@
-using UVtools.GUI.Controls;
-
-namespace UVtools.GUI.Forms
-{
- partial class FrmMutationMask
- {
- ///
- /// Required designer variable.
- ///
- private System.ComponentModel.IContainer components = null;
-
- ///
- /// Clean up any resources being used.
- ///
- /// true if managed resources should be disposed; otherwise, false.
- protected override void Dispose(bool disposing)
- {
- if (disposing && (components != null))
- {
- components.Dispose();
- }
- base.Dispose(disposing);
- }
-
- #region Windows Form Designer generated code
-
- ///
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- ///
- private void InitializeComponent()
- {
- this.components = new System.ComponentModel.Container();
- System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FrmMutationMask));
- this.lbDescription = new System.Windows.Forms.Label();
- this.lbLayerRange = new System.Windows.Forms.Label();
- this.nmLayerRangeStart = new System.Windows.Forms.NumericUpDown();
- this.nmLayerRangeEnd = new System.Windows.Forms.NumericUpDown();
- this.lbLayerRangeTo = new System.Windows.Forms.Label();
- this.cmLayerRange = new System.Windows.Forms.ContextMenuStrip(this.components);
- this.btnLayerRangeAllLayers = new System.Windows.Forms.ToolStripMenuItem();
- this.btnLayerRangeCurrentLayer = new System.Windows.Forms.ToolStripMenuItem();
- this.btnLayerRangeBottomLayers = new System.Windows.Forms.ToolStripMenuItem();
- this.btnLayerRangeNormalLayers = new System.Windows.Forms.ToolStripMenuItem();
- this.btnCancel = new System.Windows.Forms.Button();
- this.btnMutate = new System.Windows.Forms.Button();
- this.toolTip = new System.Windows.Forms.ToolTip(this.components);
- this.btnLayerRangeSelect = new UVtools.GUI.Controls.SplitButton();
- this.btnImportImageMask = new System.Windows.Forms.Button();
- this.groupBox1 = new System.Windows.Forms.GroupBox();
- this.pbMask = new System.Windows.Forms.PictureBox();
- this.lbPrinterResolution = new System.Windows.Forms.Label();
- this.lbMaskResolution = new System.Windows.Forms.Label();
- this.cbInvertMask = new System.Windows.Forms.CheckBox();
- this.groupBox2 = new System.Windows.Forms.GroupBox();
- this.nmGeneratorMinBrightness = new System.Windows.Forms.NumericUpDown();
- this.label1 = new System.Windows.Forms.Label();
- this.label2 = new System.Windows.Forms.Label();
- this.nmGeneratorMaxBrightness = new System.Windows.Forms.NumericUpDown();
- this.label3 = new System.Windows.Forms.Label();
- this.label4 = new System.Windows.Forms.Label();
- this.nmGeneratorDiameter = new System.Windows.Forms.NumericUpDown();
- this.btnMaskGenerate = new System.Windows.Forms.Button();
- ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).BeginInit();
- this.cmLayerRange.SuspendLayout();
- this.groupBox1.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.pbMask)).BeginInit();
- this.groupBox2.SuspendLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).BeginInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).BeginInit();
- this.SuspendLayout();
- //
- // lbDescription
- //
- this.lbDescription.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.lbDescription.Location = new System.Drawing.Point(13, 14);
- this.lbDescription.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.lbDescription.Name = "lbDescription";
- this.lbDescription.Size = new System.Drawing.Size(584, 128);
- this.lbDescription.TabIndex = 0;
- this.lbDescription.Text = "Description";
- //
- // lbLayerRange
- //
- this.lbLayerRange.AutoSize = true;
- this.lbLayerRange.Location = new System.Drawing.Point(13, 150);
- this.lbLayerRange.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.lbLayerRange.Name = "lbLayerRange";
- this.lbLayerRange.Size = new System.Drawing.Size(97, 20);
- this.lbLayerRange.TabIndex = 9;
- this.lbLayerRange.Text = "Layer range:";
- this.toolTip.SetToolTip(this.lbLayerRange, resources.GetString("lbLayerRange.ToolTip"));
- //
- // nmLayerRangeStart
- //
- this.nmLayerRangeStart.Location = new System.Drawing.Point(118, 147);
- this.nmLayerRangeStart.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.nmLayerRangeStart.Maximum = new decimal(new int[] {
- 100000,
- 0,
- 0,
- 0});
- this.nmLayerRangeStart.Name = "nmLayerRangeStart";
- this.nmLayerRangeStart.Size = new System.Drawing.Size(120, 26);
- this.nmLayerRangeStart.TabIndex = 0;
- //
- // nmLayerRangeEnd
- //
- this.nmLayerRangeEnd.Location = new System.Drawing.Point(314, 147);
- this.nmLayerRangeEnd.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.nmLayerRangeEnd.Maximum = new decimal(new int[] {
- 100000,
- 0,
- 0,
- 0});
- this.nmLayerRangeEnd.Name = "nmLayerRangeEnd";
- this.nmLayerRangeEnd.Size = new System.Drawing.Size(120, 26);
- this.nmLayerRangeEnd.TabIndex = 1;
- //
- // lbLayerRangeTo
- //
- this.lbLayerRangeTo.AutoSize = true;
- this.lbLayerRangeTo.Location = new System.Drawing.Point(275, 150);
- this.lbLayerRangeTo.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
- this.lbLayerRangeTo.Name = "lbLayerRangeTo";
- this.lbLayerRangeTo.Size = new System.Drawing.Size(31, 20);
- this.lbLayerRangeTo.TabIndex = 12;
- this.lbLayerRangeTo.Text = "To:";
- //
- // cmLayerRange
- //
- this.cmLayerRange.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
- this.btnLayerRangeAllLayers,
- this.btnLayerRangeCurrentLayer,
- this.btnLayerRangeBottomLayers,
- this.btnLayerRangeNormalLayers});
- this.cmLayerRange.Name = "cmLayerRange";
- this.cmLayerRange.Size = new System.Drawing.Size(226, 92);
- //
- // btnLayerRangeAllLayers
- //
- this.btnLayerRangeAllLayers.Name = "btnLayerRangeAllLayers";
- this.btnLayerRangeAllLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
- | System.Windows.Forms.Keys.A)));
- this.btnLayerRangeAllLayers.Size = new System.Drawing.Size(225, 22);
- this.btnLayerRangeAllLayers.Text = "&All Layers";
- this.btnLayerRangeAllLayers.Click += new System.EventHandler(this.ItemClicked);
- //
- // btnLayerRangeCurrentLayer
- //
- this.btnLayerRangeCurrentLayer.Name = "btnLayerRangeCurrentLayer";
- this.btnLayerRangeCurrentLayer.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
- | System.Windows.Forms.Keys.C)));
- this.btnLayerRangeCurrentLayer.Size = new System.Drawing.Size(225, 22);
- this.btnLayerRangeCurrentLayer.Text = "&Current Layer";
- this.btnLayerRangeCurrentLayer.Click += new System.EventHandler(this.ItemClicked);
- //
- // btnLayerRangeBottomLayers
- //
- this.btnLayerRangeBottomLayers.Name = "btnLayerRangeBottomLayers";
- this.btnLayerRangeBottomLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
- | System.Windows.Forms.Keys.B)));
- this.btnLayerRangeBottomLayers.Size = new System.Drawing.Size(225, 22);
- this.btnLayerRangeBottomLayers.Text = "&Bottom Layers";
- this.btnLayerRangeBottomLayers.Click += new System.EventHandler(this.ItemClicked);
- //
- // btnLayerRangeNormalLayers
- //
- this.btnLayerRangeNormalLayers.Name = "btnLayerRangeNormalLayers";
- this.btnLayerRangeNormalLayers.ShortcutKeys = ((System.Windows.Forms.Keys)(((System.Windows.Forms.Keys.Control | System.Windows.Forms.Keys.Shift)
- | System.Windows.Forms.Keys.N)));
- this.btnLayerRangeNormalLayers.Size = new System.Drawing.Size(225, 22);
- this.btnLayerRangeNormalLayers.Text = "&Normal Layers";
- this.btnLayerRangeNormalLayers.Click += new System.EventHandler(this.ItemClicked);
- //
- // btnCancel
- //
- this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
- this.btnCancel.Image = global::UVtools.GUI.Properties.Resources.Cancel_24x24;
- this.btnCancel.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnCancel.Location = new System.Drawing.Point(434, 733);
- this.btnCancel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.btnCancel.Name = "btnCancel";
- this.btnCancel.Size = new System.Drawing.Size(150, 48);
- this.btnCancel.TabIndex = 6;
- this.btnCancel.Text = "&Cancel";
- this.btnCancel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.btnCancel.UseVisualStyleBackColor = true;
- this.btnCancel.Click += new System.EventHandler(this.ItemClicked);
- //
- // btnMutate
- //
- this.btnMutate.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
- this.btnMutate.Enabled = false;
- this.btnMutate.Image = global::UVtools.GUI.Properties.Resources.Ok_24x24;
- this.btnMutate.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
- this.btnMutate.Location = new System.Drawing.Point(276, 733);
- this.btnMutate.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.btnMutate.Name = "btnMutate";
- this.btnMutate.Size = new System.Drawing.Size(150, 48);
- this.btnMutate.TabIndex = 5;
- this.btnMutate.Text = "&Mutate";
- this.btnMutate.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
- this.btnMutate.UseVisualStyleBackColor = true;
- this.btnMutate.Click += new System.EventHandler(this.ItemClicked);
- //
- // toolTip
- //
- this.toolTip.AutoPopDelay = 32767;
- this.toolTip.InitialDelay = 500;
- this.toolTip.IsBalloon = true;
- this.toolTip.ReshowDelay = 100;
- this.toolTip.ToolTipIcon = System.Windows.Forms.ToolTipIcon.Info;
- this.toolTip.ToolTipTitle = "Information";
- //
- // btnLayerRangeSelect
- //
- this.btnLayerRangeSelect.Location = new System.Drawing.Point(446, 146);
- this.btnLayerRangeSelect.Menu = this.cmLayerRange;
- this.btnLayerRangeSelect.Name = "btnLayerRangeSelect";
- this.btnLayerRangeSelect.Size = new System.Drawing.Size(138, 26);
- this.btnLayerRangeSelect.TabIndex = 2;
- this.btnLayerRangeSelect.Text = "Select";
- this.btnLayerRangeSelect.UseVisualStyleBackColor = true;
- //
- // btnImportImageMask
- //
- this.btnImportImageMask.Location = new System.Drawing.Point(17, 181);
- this.btnImportImageMask.Name = "btnImportImageMask";
- this.btnImportImageMask.Size = new System.Drawing.Size(417, 32);
- this.btnImportImageMask.TabIndex = 31;
- this.btnImportImageMask.Text = "Import grayscale mask image from file";
- this.btnImportImageMask.UseVisualStyleBackColor = true;
- this.btnImportImageMask.Click += new System.EventHandler(this.ItemClicked);
- //
- // groupBox1
- //
- this.groupBox1.Controls.Add(this.pbMask);
- this.groupBox1.Location = new System.Drawing.Point(14, 387);
- this.groupBox1.Name = "groupBox1";
- this.groupBox1.Size = new System.Drawing.Size(567, 335);
- this.groupBox1.TabIndex = 32;
- this.groupBox1.TabStop = false;
- this.groupBox1.Text = "Mask image";
- //
- // pbMask
- //
- this.pbMask.Dock = System.Windows.Forms.DockStyle.Fill;
- this.pbMask.Location = new System.Drawing.Point(3, 22);
- this.pbMask.Name = "pbMask";
- this.pbMask.Size = new System.Drawing.Size(561, 310);
- this.pbMask.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
- this.pbMask.TabIndex = 0;
- this.pbMask.TabStop = false;
- //
- // lbPrinterResolution
- //
- this.lbPrinterResolution.AutoSize = true;
- this.lbPrinterResolution.Location = new System.Drawing.Point(13, 322);
- this.lbPrinterResolution.Name = "lbPrinterResolution";
- this.lbPrinterResolution.Size = new System.Drawing.Size(136, 20);
- this.lbPrinterResolution.TabIndex = 33;
- this.lbPrinterResolution.Text = "Printer resolution: ";
- //
- // lbMaskResolution
- //
- this.lbMaskResolution.AutoSize = true;
- this.lbMaskResolution.Location = new System.Drawing.Point(13, 352);
- this.lbMaskResolution.Name = "lbMaskResolution";
- this.lbMaskResolution.Size = new System.Drawing.Size(207, 20);
- this.lbMaskResolution.TabIndex = 34;
- this.lbMaskResolution.Text = "Mask resolution: (Unloaded)";
- //
- // cbInvertMask
- //
- this.cbInvertMask.AutoSize = true;
- this.cbInvertMask.Location = new System.Drawing.Point(446, 186);
- this.cbInvertMask.Name = "cbInvertMask";
- this.cbInvertMask.Size = new System.Drawing.Size(110, 24);
- this.cbInvertMask.TabIndex = 35;
- this.cbInvertMask.Text = "Invert Mask";
- this.cbInvertMask.UseVisualStyleBackColor = true;
- this.cbInvertMask.CheckedChanged += new System.EventHandler(this.ItemClicked);
- //
- // groupBox2
- //
- this.groupBox2.Controls.Add(this.btnMaskGenerate);
- this.groupBox2.Controls.Add(this.label4);
- this.groupBox2.Controls.Add(this.nmGeneratorDiameter);
- this.groupBox2.Controls.Add(this.label3);
- this.groupBox2.Controls.Add(this.label2);
- this.groupBox2.Controls.Add(this.nmGeneratorMaxBrightness);
- this.groupBox2.Controls.Add(this.label1);
- this.groupBox2.Controls.Add(this.nmGeneratorMinBrightness);
- this.groupBox2.Location = new System.Drawing.Point(17, 219);
- this.groupBox2.Name = "groupBox2";
- this.groupBox2.Size = new System.Drawing.Size(564, 96);
- this.groupBox2.TabIndex = 36;
- this.groupBox2.TabStop = false;
- this.groupBox2.Text = "Mask Generator (Round from center)";
- //
- // nmGeneratorMinBrightness
- //
- this.nmGeneratorMinBrightness.Location = new System.Drawing.Point(166, 25);
- this.nmGeneratorMinBrightness.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.nmGeneratorMinBrightness.Name = "nmGeneratorMinBrightness";
- this.nmGeneratorMinBrightness.Size = new System.Drawing.Size(78, 26);
- this.nmGeneratorMinBrightness.TabIndex = 0;
- this.nmGeneratorMinBrightness.Value = new decimal(new int[] {
- 200,
- 0,
- 0,
- 0});
- //
- // label1
- //
- this.label1.AutoSize = true;
- this.label1.Location = new System.Drawing.Point(6, 28);
- this.label1.Name = "label1";
- this.label1.Size = new System.Drawing.Size(154, 20);
- this.label1.TabIndex = 35;
- this.label1.Text = "Minimum brightness:";
- //
- // label2
- //
- this.label2.AutoSize = true;
- this.label2.Location = new System.Drawing.Point(320, 28);
- this.label2.Name = "label2";
- this.label2.Size = new System.Drawing.Size(158, 20);
- this.label2.TabIndex = 37;
- this.label2.Text = "Maximum brightness:";
- //
- // nmGeneratorMaxBrightness
- //
- this.nmGeneratorMaxBrightness.Location = new System.Drawing.Point(480, 25);
- this.nmGeneratorMaxBrightness.Maximum = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- this.nmGeneratorMaxBrightness.Name = "nmGeneratorMaxBrightness";
- this.nmGeneratorMaxBrightness.Size = new System.Drawing.Size(78, 26);
- this.nmGeneratorMaxBrightness.TabIndex = 36;
- this.nmGeneratorMaxBrightness.Value = new decimal(new int[] {
- 255,
- 0,
- 0,
- 0});
- //
- // label3
- //
- this.label3.AutoSize = true;
- this.label3.Location = new System.Drawing.Point(255, 28);
- this.label3.Name = "label3";
- this.label3.Size = new System.Drawing.Size(60, 20);
- this.label3.TabIndex = 38;
- this.label3.Text = "(0-255)";
- //
- // label4
- //
- this.label4.AutoSize = true;
- this.label4.Location = new System.Drawing.Point(6, 60);
- this.label4.Name = "label4";
- this.label4.Size = new System.Drawing.Size(137, 20);
- this.label4.TabIndex = 40;
- this.label4.Text = "Diameter in pixels:";
- //
- // nmGeneratorDiameter
- //
- this.nmGeneratorDiameter.Location = new System.Drawing.Point(166, 57);
- this.nmGeneratorDiameter.Maximum = new decimal(new int[] {
- 10000,
- 0,
- 0,
- 0});
- this.nmGeneratorDiameter.Name = "nmGeneratorDiameter";
- this.nmGeneratorDiameter.Size = new System.Drawing.Size(78, 26);
- this.nmGeneratorDiameter.TabIndex = 39;
- //
- // btnMaskGenerate
- //
- this.btnMaskGenerate.Location = new System.Drawing.Point(259, 57);
- this.btnMaskGenerate.Name = "btnMaskGenerate";
- this.btnMaskGenerate.Size = new System.Drawing.Size(299, 26);
- this.btnMaskGenerate.TabIndex = 41;
- this.btnMaskGenerate.Text = "Generate";
- this.btnMaskGenerate.UseVisualStyleBackColor = true;
- this.btnMaskGenerate.Click += new System.EventHandler(this.ItemClicked);
- //
- // FrmMutationMask
- //
- this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 20F);
- this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
- this.CancelButton = this.btnCancel;
- this.ClientSize = new System.Drawing.Size(599, 795);
- this.Controls.Add(this.groupBox2);
- this.Controls.Add(this.cbInvertMask);
- this.Controls.Add(this.lbMaskResolution);
- this.Controls.Add(this.lbPrinterResolution);
- this.Controls.Add(this.groupBox1);
- this.Controls.Add(this.btnImportImageMask);
- this.Controls.Add(this.btnLayerRangeSelect);
- this.Controls.Add(this.lbLayerRangeTo);
- this.Controls.Add(this.nmLayerRangeEnd);
- this.Controls.Add(this.nmLayerRangeStart);
- this.Controls.Add(this.lbLayerRange);
- this.Controls.Add(this.btnMutate);
- this.Controls.Add(this.btnCancel);
- this.Controls.Add(this.lbDescription);
- this.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
- this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
- this.KeyPreview = true;
- this.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
- this.MaximizeBox = false;
- this.MinimizeBox = false;
- this.Name = "FrmMutationMask";
- this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
- this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
- this.Text = "Form1";
- this.TopMost = true;
- ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeStart)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmLayerRangeEnd)).EndInit();
- this.cmLayerRange.ResumeLayout(false);
- this.groupBox1.ResumeLayout(false);
- ((System.ComponentModel.ISupportInitialize)(this.pbMask)).EndInit();
- this.groupBox2.ResumeLayout(false);
- this.groupBox2.PerformLayout();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMinBrightness)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorMaxBrightness)).EndInit();
- ((System.ComponentModel.ISupportInitialize)(this.nmGeneratorDiameter)).EndInit();
- this.ResumeLayout(false);
- this.PerformLayout();
-
- }
-
- #endregion
-
- private System.Windows.Forms.Label lbDescription;
- private System.Windows.Forms.Button btnCancel;
- private System.Windows.Forms.Button btnMutate;
- private System.Windows.Forms.Label lbLayerRange;
- private System.Windows.Forms.NumericUpDown nmLayerRangeStart;
- private System.Windows.Forms.NumericUpDown nmLayerRangeEnd;
- private System.Windows.Forms.Label lbLayerRangeTo;
- private Controls.SplitButton btnLayerRangeSelect;
- private System.Windows.Forms.ContextMenuStrip cmLayerRange;
- private System.Windows.Forms.ToolStripMenuItem btnLayerRangeAllLayers;
- private System.Windows.Forms.ToolStripMenuItem btnLayerRangeCurrentLayer;
- private System.Windows.Forms.ToolStripMenuItem btnLayerRangeBottomLayers;
- private System.Windows.Forms.ToolStripMenuItem btnLayerRangeNormalLayers;
- private System.Windows.Forms.ToolTip toolTip;
- private System.Windows.Forms.Button btnImportImageMask;
- private System.Windows.Forms.GroupBox groupBox1;
- private System.Windows.Forms.PictureBox pbMask;
- private System.Windows.Forms.Label lbPrinterResolution;
- private System.Windows.Forms.Label lbMaskResolution;
- private System.Windows.Forms.CheckBox cbInvertMask;
- private System.Windows.Forms.GroupBox groupBox2;
- private System.Windows.Forms.Label label2;
- private System.Windows.Forms.NumericUpDown nmGeneratorMaxBrightness;
- private System.Windows.Forms.Label label1;
- private System.Windows.Forms.NumericUpDown nmGeneratorMinBrightness;
- private System.Windows.Forms.Label label3;
- private System.Windows.Forms.Label label4;
- private System.Windows.Forms.NumericUpDown nmGeneratorDiameter;
- private System.Windows.Forms.Button btnMaskGenerate;
- }
-}
\ No newline at end of file
diff --git a/UVtools.GUI/Forms/FrmMutationMask.cs b/UVtools.GUI/Forms/FrmMutationMask.cs
deleted file mode 100644
index eded54c..0000000
--- a/UVtools.GUI/Forms/FrmMutationMask.cs
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * GNU AFFERO GENERAL PUBLIC LICENSE
- * Version 3, 19 November 2007
- * Copyright (C) 2007 Free Software Foundation, Inc.
- * Everyone is permitted to copy and distribute verbatim copies
- * of this license document, but changing it is not allowed.
- */
-
-using System;
-using System.Drawing;
-using System.Windows.Forms;
-using Emgu.CV;
-using Emgu.CV.CvEnum;
-using Emgu.CV.Structure;
-using UVtools.Core.Extensions;
-using UVtools.GUI.Extensions;
-
-namespace UVtools.GUI.Forms
-{
- public partial class FrmMutationMask : Form
- {
- #region Properties
-
- private Mutation Mutation { get; }
-
- public uint LayerRangeStart
- {
- get => (uint) nmLayerRangeStart.Value;
- set => nmLayerRangeStart.Value = value;
- }
-
- public uint LayerRangeEnd
- {
- get => (uint)Math.Min(nmLayerRangeEnd.Value, Program.SlicerFile.LayerCount-1);
- set => nmLayerRangeEnd.Value = value;
- }
-
- public Mat Mask { get; private set; }
- #endregion
-
- #region Constructors
- public FrmMutationMask(Mutation mutation)
- {
- InitializeComponent();
- Mutation = mutation;
-
- Text = $"Mutate: {mutation.MenuName}";
- lbDescription.Text = Mutation.Description;
-
- nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
- lbPrinterResolution.Text = $"Printer Resolution: {Program.FrmMain.ActualLayerImage.Size}";
- }
- #endregion
-
- #region Overrides
- protected override void OnKeyUp(KeyEventArgs e)
- {
- base.OnKeyUp(e);
- if (e.KeyCode == Keys.Enter)
- {
- btnMutate.PerformClick();
- e.Handled = true;
- return;
- }
-
- if ((ModifierKeys & Keys.Shift) == Keys.Shift && (ModifierKeys & Keys.Control) == Keys.Control)
- {
- if (e.KeyCode == Keys.A)
- {
- btnLayerRangeAllLayers.PerformClick();
- e.Handled = true;
- return;
- }
-
- if (e.KeyCode == Keys.C)
- {
- btnLayerRangeCurrentLayer.PerformClick();
- e.Handled = true;
- return;
- }
-
- if (e.KeyCode == Keys.B)
- {
- btnLayerRangeBottomLayers.PerformClick();
- e.Handled = true;
- return;
- }
-
- if (e.KeyCode == Keys.N)
- {
- btnLayerRangeNormalLayers.PerformClick();
- e.Handled = true;
- return;
- }
- }
- }
-
- #endregion
-
- #region Events
- private void ItemClicked(object sender, EventArgs e)
- {
- if (ReferenceEquals(sender, btnLayerRangeAllLayers))
- {
- nmLayerRangeStart.Value = 0;
- nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount-1;
- return;
- }
-
- if (ReferenceEquals(sender, btnLayerRangeCurrentLayer))
- {
- nmLayerRangeStart.Value = Program.FrmMain.ActualLayer;
- nmLayerRangeEnd.Value = Program.FrmMain.ActualLayer;
- return;
- }
-
- if (ReferenceEquals(sender, btnLayerRangeBottomLayers))
- {
- nmLayerRangeStart.Value = 0;
- nmLayerRangeEnd.Value = Program.SlicerFile.InitialLayerCount-1;
- return;
- }
-
- if (ReferenceEquals(sender, btnLayerRangeNormalLayers))
- {
- nmLayerRangeStart.Value = Program.SlicerFile.InitialLayerCount - 1;
- nmLayerRangeEnd.Value = Program.SlicerFile.LayerCount - 1;
- return;
- }
-
- if (ReferenceEquals(sender, btnImportImageMask))
- {
- using (var fileOpen = new OpenFileDialog
- {
- CheckFileExists = true,
- Filter = "Image Files(*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF)|*.PNG;*.BMP;*.JPEG;*.JPG;*.GIF"
- })
- {
- if (fileOpen.ShowDialog() != DialogResult.OK) return;
-
- Mask = CvInvoke.Imread(fileOpen.FileName, ImreadModes.Grayscale);
-
- if (Mask.Size != Program.FrmMain.ActualLayerImage.Size)
- {
- CvInvoke.Resize(Mask, Mask, Program.FrmMain.ActualLayerImage.Size);
- }
-
- if (cbInvertMask.Checked)
- {
- CvInvoke.BitwiseNot(Mask, Mask);
- }
-
- lbMaskResolution.Text = $"Mask Resolution: {Mask.Size}";
-
- pbMask.Image = Mask.ToBitmap();
- btnMutate.Enabled = true;
- }
- return;
- }
-
- if (ReferenceEquals(sender, cbInvertMask))
- {
- CvInvoke.BitwiseNot(Mask, Mask);
- pbMask.Image = Mask.ToBitmap();
- return;
- }
-
- if (ReferenceEquals(sender, btnMaskGenerate))
- {
- Mask = Program.FrmMain.ActualLayerImage.CloneBlank();
- lbMaskResolution.Text = $"Mask Resolution: {Mask.Size}";
-
- int radius = (int) nmGeneratorDiameter.Value;
- if (radius == 0)
- {
- radius = Math.Min(Mask.Width, Mask.Height) / 2;
- }
- else
- {
- radius = radius.Clamp(2, Math.Min(Mask.Width, Mask.Height)) / 2;
- }
-
- var maxScalar = new MCvScalar((double)nmGeneratorMaxBrightness.Value);
- Mask.SetTo(maxScalar);
-
- var center = new Point(Mask.Width / 2, Mask.Height / 2);
- var colorDifference = nmGeneratorMinBrightness.Value - nmGeneratorMaxBrightness.Value;
- //CvInvoke.Circle(Mask, center, radius, minScalar, -1);
-
- for (decimal i = 1; i < radius; i++)
- {
- int color = (int) (nmGeneratorMinBrightness.Value - i / radius * colorDifference); //or some another color calculation
- CvInvoke.Circle(Mask, center, (int) i, new MCvScalar(color), 2);
- }
-
- if (cbInvertMask.Checked)
- CvInvoke.BitwiseNot(Mask, Mask);
- pbMask.Image = Mask.ToBitmap();
- btnMutate.Enabled = true;
- return;
- }
-
- if (ReferenceEquals(sender, btnMutate))
- {
- if (!btnMutate.Enabled) return;
- if (LayerRangeStart > LayerRangeEnd)
- {
- MessageBox.Show("Layer range start can't be higher than layer end.\nPlease fix and try again.", Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
- nmLayerRangeStart.Select();
- return;
- }
-
- if (MessageBox.Show($"Are you sure you want to {Mutation.Mutate}?", Text, MessageBoxButtons.YesNo,
- MessageBoxIcon.Question) != DialogResult.Yes) return;
-
- DialogResult = DialogResult.OK;
- Close();
-
- return;
- }
-
- if (ReferenceEquals(sender, btnCancel))
- {
- Mask?.Dispose();
- DialogResult = DialogResult.Cancel;
- return;
- }
- }
-
-
- #endregion
- }
-}
diff --git a/UVtools.GUI/Forms/FrmToolWindow.cs b/UVtools.GUI/Forms/FrmToolWindow.cs
index b5a8ac1..ebdb861 100644
--- a/UVtools.GUI/Forms/FrmToolWindow.cs
+++ b/UVtools.GUI/Forms/FrmToolWindow.cs
@@ -140,6 +140,7 @@ namespace UVtools.GUI.Forms
//content.Dock = DockStyle.Fill;
btnResetDefaults.Visible = content.ButtonResetDefaultsVisible;
btnOk.Enabled = content.ButtonOkEnabled;
+ //content.AutoSize = true;
Content = content;
content.PropertyChanged += ContentOnPropertyChanged;
diff --git a/UVtools.GUI/FrmMain.cs b/UVtools.GUI/FrmMain.cs
index a96c0fe..ed12e87 100644
--- a/UVtools.GUI/FrmMain.cs
+++ b/UVtools.GUI/FrmMain.cs
@@ -51,6 +51,7 @@ namespace UVtools.GUI
new OperationMenuItem(new OperationRotate(), Resources.Rotate_16x16),
new OperationMenuItem(new OperationSolidify(), Resources.square_solid_16x16),
new OperationMenuItem(new OperationMorph(), Resources.Geometry_16x16),
+ new OperationMenuItem(new OperationMask(), Resources.mask_16x16),
new OperationMenuItem(new OperationChangeResolution(), Resources.resize_16x16),
new OperationMenuItem(new OperationLayerReHeight(), Resources.ladder_16x16),
new OperationMenuItem(new OperationPattern(), Resources.pattern_16x16)
@@ -101,7 +102,7 @@ namespace UVtools.GUI
Resources.mutation_solidify
)
},*/
- {
+ /*{
LayerManager.Mutate.Mask, new Mutation(LayerManager.Mutate.Mask, "Mask", Resources.mask_16x16,
"Masks the LCD output image given a greyscale (0-255) pixel input image.\n" +
"Useful to correct light uniformity, but a proper mask must be created first based on real measurements per printer.\n" +
@@ -109,7 +110,7 @@ namespace UVtools.GUI
"NOTE 2: Run only this tool after all repairs and other transformations.",
"Mask"
)
- },
+ },*/
{
LayerManager.Mutate.PixelDimming, new Mutation(LayerManager.Mutate.PixelDimming, "Pixel Dimming",
Resources.chessboard_16x16,
@@ -3652,10 +3653,6 @@ namespace UVtools.GUI
ThresholdType thresholdType = ThresholdType.Binary;
- double x = 0;
-
- Mat mat = null;
-
Matrix evenPattern = null;
Matrix oddPattern = null;
@@ -3693,7 +3690,7 @@ namespace UVtools.GUI
}
break;*/
- case LayerManager.Mutate.Mask:
+ /*case LayerManager.Mutate.Mask:
using (FrmMutationMask inputBox = new FrmMutationMask(Mutations[mutator]))
{
if (inputBox.ShowDialog() != DialogResult.OK) return;
@@ -3702,7 +3699,7 @@ namespace UVtools.GUI
mat = inputBox.Mask;
}
- break;
+ break;*/
case LayerManager.Mutate.PixelDimming:
using (FrmMutationPixelDimming inputBox = new FrmMutationPixelDimming(Mutations[mutator]))
{
@@ -3782,10 +3779,10 @@ namespace UVtools.GUI
/*case LayerManager.Mutate.Solidify:
SlicerFile.LayerManager.Solidify(layerStart, layerEnd, progress);
break;*/
- case LayerManager.Mutate.Mask:
- SlicerFile.LayerManager.MutateMask(layerStart, layerEnd, mat, progress);
+ /*case LayerManager.Mutate.Mask:
+ SlicerFile.LayerManager.Mask(layerStart, layerEnd, mat, progress);
mat?.Dispose();
- break;
+ break;*/
case LayerManager.Mutate.PixelDimming:
SlicerFile.LayerManager.MutatePixelDimming(layerStart, layerEnd, evenPattern, oddPattern,
(ushort) iterationsStart, fade, progress);
@@ -4519,6 +4516,10 @@ namespace UVtools.GUI
case OperationMorph operation:
SlicerFile.LayerManager.Morph(operation, BorderType.Default, new MCvScalar(), FrmLoading.RestartProgress());
break;
+ case OperationMask operation:
+ SlicerFile.LayerManager.Mask(operation, FrmLoading.RestartProgress());
+ break;
+
case OperationChangeResolution operation:
SlicerFile.LayerManager.ChangeResolution(operation, FrmLoading.RestartProgress(false));
break;
diff --git a/UVtools.GUI/UVtools.GUI.csproj b/UVtools.GUI/UVtools.GUI.csproj
index 2f69252..f818526 100644
--- a/UVtools.GUI/UVtools.GUI.csproj
+++ b/UVtools.GUI/UVtools.GUI.csproj
@@ -170,6 +170,12 @@
Component
+
+ UserControl
+
+
+ CtrlToolMask.cs
+
UserControl
@@ -259,12 +265,6 @@
FrmMutationBlur.cs
-
- Form
-
-
- FrmMutationMask.cs
-
Form
@@ -330,6 +330,9 @@
CtrlToolWindowContent.cs
+
+ CtrlToolMask.cs
+
CtrlToolRotate.cs
@@ -375,9 +378,6 @@
FrmMutationBlur.cs
-
- FrmMutationMask.cs
-
FrmMutationThreshold.cs