Add color-key transparency support for logo overlays

- Allow users to select a transparent color for logo images (watermarks) via UI (checkbox, color picker, preview).
- Apply color-key transparency in both System.Drawing and ImageSharp backends: specified color in logo is made fully transparent.
- Persist transparency settings in PicSettings and SettingsDto; bind to DataModel and UI controls.
- Update logo preview to reflect transparency in real time.
- Add option to select image processing library (System.Drawing or ImageSharp) in UI and settings.
- Fix bug in SettingsService parameter loading for int/double/DateTime.
- Fully integrate color-key transparency into image processing and settings serialization.
This commit is contained in:
MaddoScientisto 2026-02-15 11:13:23 +01:00
commit 8872080741
9 changed files with 732 additions and 168 deletions

View file

@ -45,6 +45,9 @@ namespace ImageCatalog
Label43 = new Label();
TabControl1 = new TabControl();
TabPage5 = new TabPage();
groupBox12 = new GroupBox();
rdbLibrary2 = new RadioButton();
rdbLibrary1 = new RadioButton();
GroupBox11 = new GroupBox();
numericUpDown2 = new NumericUpDown();
numericUpDown1 = new NumericUpDown();
@ -150,7 +153,6 @@ namespace ImageCatalog
CheckBox1 = new CheckBox();
TabPage4 = new TabPage();
GroupBox6 = new GroupBox();
PictureBox2 = new PictureBox();
_PictureBox1 = new PictureBox();
ComboBox5 = new ComboBox();
ComboBox4 = new ComboBox();
@ -167,8 +169,6 @@ namespace ImageCatalog
_Button4 = new Button();
TextBox10 = new TextBox();
Label29 = new Label();
Label30 = new Label();
PictureBox3 = new PictureBox();
versionLabel = new Label();
_Button7 = new Button();
_Button5 = new Button();
@ -181,13 +181,15 @@ namespace ImageCatalog
_btnCreaCatalogoAsync = new Button();
timer1 = new System.Windows.Forms.Timer(components);
dataModelBindingSource1 = new BindingSource(components);
groupBox12 = new GroupBox();
rdbLibrary1 = new RadioButton();
rdbLibrary2 = new RadioButton();
PictureBox3 = new PictureBox();
colorDialog1 = new ColorDialog();
btnSetTransparency = new Button();
chkUseTransparentColor = new CheckBox();
((System.ComponentModel.ISupportInitialize)bindingSource1).BeginInit();
((System.ComponentModel.ISupportInitialize)dataModelBindingSource).BeginInit();
TabControl1.SuspendLayout();
TabPage5.SuspendLayout();
groupBox12.SuspendLayout();
GroupBox11.SuspendLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown2).BeginInit();
((System.ComponentModel.ISupportInitialize)numericUpDown1).BeginInit();
@ -208,11 +210,9 @@ namespace ImageCatalog
Panel2.SuspendLayout();
TabPage4.SuspendLayout();
GroupBox6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)PictureBox2).BeginInit();
((System.ComponentModel.ISupportInitialize)_PictureBox1).BeginInit();
((System.ComponentModel.ISupportInitialize)PictureBox3).BeginInit();
((System.ComponentModel.ISupportInitialize)dataModelBindingSource1).BeginInit();
groupBox12.SuspendLayout();
((System.ComponentModel.ISupportInitialize)PictureBox3).BeginInit();
SuspendLayout();
//
// ProgressBar1
@ -286,6 +286,41 @@ namespace ImageCatalog
TabPage5.Text = "Generale";
TabPage5.UseVisualStyleBackColor = true;
//
// groupBox12
//
groupBox12.Controls.Add(rdbLibrary2);
groupBox12.Controls.Add(rdbLibrary1);
groupBox12.Location = new Point(405, 625);
groupBox12.Name = "groupBox12";
groupBox12.Size = new Size(350, 175);
groupBox12.TabIndex = 49;
groupBox12.TabStop = false;
groupBox12.Text = "Libreria Manipolazione Grafica";
//
// rdbLibrary2
//
rdbLibrary2.AutoSize = true;
rdbLibrary2.DataBindings.Add(new Binding("Checked", bindingSource1, "UseImageSharp", true, DataSourceUpdateMode.OnPropertyChanged));
rdbLibrary2.Location = new Point(12, 77);
rdbLibrary2.Name = "rdbLibrary2";
rdbLibrary2.Size = new Size(149, 34);
rdbLibrary2.TabIndex = 1;
rdbLibrary2.TabStop = true;
rdbLibrary2.Text = "ImageSharp";
rdbLibrary2.UseVisualStyleBackColor = true;
//
// rdbLibrary1
//
rdbLibrary1.AutoSize = true;
rdbLibrary1.DataBindings.Add(new Binding("Checked", bindingSource1, "UseSystemGraphics", true, DataSourceUpdateMode.OnPropertyChanged));
rdbLibrary1.Location = new Point(12, 37);
rdbLibrary1.Name = "rdbLibrary1";
rdbLibrary1.Size = new Size(188, 34);
rdbLibrary1.TabIndex = 0;
rdbLibrary1.TabStop = true;
rdbLibrary1.Text = "System.Graphics";
rdbLibrary1.UseVisualStyleBackColor = true;
//
// GroupBox11
//
GroupBox11.Controls.Add(numericUpDown2);
@ -1491,7 +1526,8 @@ namespace ImageCatalog
//
// GroupBox6
//
GroupBox6.Controls.Add(PictureBox2);
GroupBox6.Controls.Add(chkUseTransparentColor);
GroupBox6.Controls.Add(btnSetTransparency);
GroupBox6.Controls.Add(_PictureBox1);
GroupBox6.Controls.Add(ComboBox5);
GroupBox6.Controls.Add(ComboBox4);
@ -1508,29 +1544,17 @@ namespace ImageCatalog
GroupBox6.Controls.Add(_Button4);
GroupBox6.Controls.Add(TextBox10);
GroupBox6.Controls.Add(Label29);
GroupBox6.Controls.Add(Label30);
GroupBox6.Controls.Add(PictureBox3);
GroupBox6.ForeColor = Color.FromArgb(0, 0, 192);
GroupBox6.Location = new Point(12, 13);
GroupBox6.Margin = new Padding(6, 8, 6, 8);
GroupBox6.Name = "GroupBox6";
GroupBox6.Padding = new Padding(6, 8, 6, 8);
GroupBox6.Size = new Size(991, 518);
GroupBox6.Size = new Size(991, 593);
GroupBox6.TabIndex = 42;
GroupBox6.TabStop = false;
GroupBox6.Text = "Logo";
//
// PictureBox2
//
PictureBox2.BorderStyle = BorderStyle.FixedSingle;
PictureBox2.Location = new Point(288, 442);
PictureBox2.Margin = new Padding(6, 8, 6, 8);
PictureBox2.Name = "PictureBox2";
PictureBox2.Size = new Size(45, 53);
PictureBox2.TabIndex = 44;
PictureBox2.TabStop = false;
PictureBox2.Visible = false;
//
// _PictureBox1
//
_PictureBox1.Cursor = Cursors.Cross;
@ -1575,7 +1599,7 @@ namespace ImageCatalog
// Label28
//
Label28.ForeColor = Color.Black;
Label28.Location = new Point(34, 223);
Label28.Location = new Point(38, 222);
Label28.Margin = new Padding(6, 0, 6, 0);
Label28.Name = "Label28";
Label28.Size = new Size(240, 38);
@ -1587,7 +1611,7 @@ namespace ImageCatalog
//
CheckBox5.DataBindings.Add(new Binding("Checked", bindingSource1, "AddLogo", true, DataSourceUpdateMode.OnPropertyChanged));
CheckBox5.ForeColor = Color.Black;
CheckBox5.Location = new Point(0, 60);
CheckBox5.Location = new Point(12, 56);
CheckBox5.Margin = new Padding(6, 8, 6, 8);
CheckBox5.Name = "CheckBox5";
CheckBox5.Size = new Size(144, 47);
@ -1618,7 +1642,7 @@ namespace ImageCatalog
//
Label25.AutoSize = true;
Label25.ForeColor = Color.Black;
Label25.Location = new Point(34, 387);
Label25.Location = new Point(39, 390);
Label25.Margin = new Padding(6, 0, 6, 0);
Label25.Name = "Label25";
Label25.Size = new Size(183, 30);
@ -1695,7 +1719,7 @@ namespace ImageCatalog
//
Label29.AutoSize = true;
Label29.ForeColor = Color.Black;
Label29.Location = new Point(34, 339);
Label29.Location = new Point(38, 341);
Label29.Margin = new Padding(6, 0, 6, 0);
Label29.Name = "Label29";
Label29.Size = new Size(208, 30);
@ -1703,30 +1727,6 @@ namespace ImageCatalog
Label29.Text = "Posizione orizzontale";
Label29.TextAlign = ContentAlignment.MiddleLeft;
//
// Label30
//
Label30.AutoSize = true;
Label30.ForeColor = Color.Black;
Label30.Location = new Point(38, 468);
Label30.Margin = new Padding(6, 0, 6, 0);
Label30.Name = "Label30";
Label30.Size = new Size(184, 30);
Label30.TabIndex = 36;
Label30.Text = "Colore trasparente";
Label30.TextAlign = ContentAlignment.MiddleLeft;
Label30.Visible = false;
//
// PictureBox3
//
PictureBox3.BorderStyle = BorderStyle.FixedSingle;
PictureBox3.Location = new Point(432, 442);
PictureBox3.Margin = new Padding(6, 8, 6, 8);
PictureBox3.Name = "PictureBox3";
PictureBox3.Size = new Size(45, 53);
PictureBox3.TabIndex = 44;
PictureBox3.TabStop = false;
PictureBox3.Visible = false;
//
// versionLabel
//
versionLabel.DataBindings.Add(new Binding("Text", bindingSource1, "AppVersion", true));
@ -1842,40 +1842,35 @@ namespace ImageCatalog
//
dataModelBindingSource1.DataSource = typeof(ImageCatalog_2.DataModel);
//
// groupBox12
// PictureBox3
//
groupBox12.Controls.Add(rdbLibrary2);
groupBox12.Controls.Add(rdbLibrary1);
groupBox12.Location = new Point(405, 625);
groupBox12.Name = "groupBox12";
groupBox12.Size = new Size(350, 175);
groupBox12.TabIndex = 49;
groupBox12.TabStop = false;
groupBox12.Text = "Libreria Manipolazione Grafica";
PictureBox3.BorderStyle = BorderStyle.FixedSingle;
PictureBox3.Location = new Point(432, 442);
PictureBox3.Margin = new Padding(6, 8, 6, 8);
PictureBox3.Name = "PictureBox3";
PictureBox3.Size = new Size(45, 53);
PictureBox3.TabIndex = 44;
PictureBox3.TabStop = false;
PictureBox3.Visible = false;
//
// rdbLibrary1
// btnSetTransparency
//
rdbLibrary1.AutoSize = true;
rdbLibrary1.Location = new Point(12, 37);
rdbLibrary1.Name = "rdbLibrary1";
rdbLibrary1.Size = new Size(188, 34);
rdbLibrary1.TabIndex = 0;
rdbLibrary1.TabStop = true;
rdbLibrary1.Text = "System.Graphics";
rdbLibrary1.DataBindings.Add(new Binding("Checked", bindingSource1, "UseSystemGraphics", true, DataSourceUpdateMode.OnPropertyChanged));
rdbLibrary1.UseVisualStyleBackColor = true;
btnSetTransparency.Location = new Point(288, 455);
btnSetTransparency.Name = "btnSetTransparency";
btnSetTransparency.Size = new Size(131, 40);
btnSetTransparency.TabIndex = 45;
btnSetTransparency.Text = "Imposta";
btnSetTransparency.UseVisualStyleBackColor = true;
//
// rdbLibrary2
// chkUseTransparentColor
//
rdbLibrary2.AutoSize = true;
rdbLibrary2.Location = new Point(12, 77);
rdbLibrary2.Name = "rdbLibrary2";
rdbLibrary2.Size = new Size(149, 34);
rdbLibrary2.TabIndex = 1;
rdbLibrary2.TabStop = true;
rdbLibrary2.Text = "ImageSharp";
rdbLibrary2.DataBindings.Add(new Binding("Checked", bindingSource1, "UseImageSharp", true, DataSourceUpdateMode.OnPropertyChanged));
rdbLibrary2.UseVisualStyleBackColor = true;
chkUseTransparentColor.AutoSize = true;
chkUseTransparentColor.Location = new Point(39, 461);
chkUseTransparentColor.Name = "chkUseTransparentColor";
chkUseTransparentColor.Size = new Size(210, 34);
chkUseTransparentColor.TabIndex = 46;
chkUseTransparentColor.Text = "Colore trasparente";
chkUseTransparentColor.UseVisualStyleBackColor = true;
//
// MainForm
//
@ -1905,6 +1900,8 @@ namespace ImageCatalog
((System.ComponentModel.ISupportInitialize)dataModelBindingSource).EndInit();
TabControl1.ResumeLayout(false);
TabPage5.ResumeLayout(false);
groupBox12.ResumeLayout(false);
groupBox12.PerformLayout();
GroupBox11.ResumeLayout(false);
GroupBox11.PerformLayout();
((System.ComponentModel.ISupportInitialize)numericUpDown2).EndInit();
@ -1939,12 +1936,9 @@ namespace ImageCatalog
TabPage4.ResumeLayout(false);
GroupBox6.ResumeLayout(false);
GroupBox6.PerformLayout();
((System.ComponentModel.ISupportInitialize)PictureBox2).EndInit();
((System.ComponentModel.ISupportInitialize)_PictureBox1).EndInit();
((System.ComponentModel.ISupportInitialize)PictureBox3).EndInit();
((System.ComponentModel.ISupportInitialize)dataModelBindingSource1).EndInit();
groupBox12.ResumeLayout(false);
groupBox12.PerformLayout();
((System.ComponentModel.ISupportInitialize)PictureBox3).EndInit();
ResumeLayout(false);
PerformLayout();
}
@ -2145,7 +2139,6 @@ namespace ImageCatalog
internal CheckBox CheckBox1;
internal TabPage TabPage4;
internal GroupBox GroupBox6;
internal PictureBox PictureBox2;
private PictureBox _PictureBox1;
internal PictureBox PictureBox1
@ -2194,8 +2187,6 @@ namespace ImageCatalog
internal TextBox TextBox10;
internal Label Label29;
internal Label Label30;
internal PictureBox PictureBox3;
private Label _Label27;
internal Label Label27
@ -2298,6 +2289,10 @@ namespace ImageCatalog
private GroupBox groupBox12;
private RadioButton rdbLibrary2;
private RadioButton rdbLibrary1;
internal PictureBox PictureBox3;
private ColorDialog colorDialog1;
private Button btnSetTransparency;
private CheckBox chkUseTransparentColor;
internal Button btnCreaCatalogoAsync
{