Rename selective color value to threshold

This commit is contained in:
Jaex 2018-05-09 00:24:05 +03:00
parent 5a6e305bc2
commit dae4809133
6 changed files with 14 additions and 30 deletions

View file

@ -102,28 +102,28 @@ private void InitializeComponent()
this.btnCancel = new System.Windows.Forms.Button();
this.txtInputText = new System.Windows.Forms.TextBox();
this.SuspendLayout();
//
//
// btnOK
//
//
resources.ApplyResources(this.btnOK, "btnOK");
this.btnOK.Name = "btnOK";
this.btnOK.UseVisualStyleBackColor = true;
this.btnOK.Click += new System.EventHandler(this.btnOK_Click);
//
//
// btnCancel
//
//
resources.ApplyResources(this.btnCancel, "btnCancel");
this.btnCancel.Name = "btnCancel";
this.btnCancel.UseVisualStyleBackColor = true;
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
//
//
// txtInputText
//
//
resources.ApplyResources(this.txtInputText, "txtInputText");
this.txtInputText.Name = "txtInputText";
//
//
// InputBox
//
//
this.AcceptButton = this.btnOK;
resources.ApplyResources(this, "$this");
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;

View file

@ -1876,14 +1876,14 @@ private static RotateFlipType GetRotateFlipTypeByExifOrientationData(int orienta
}
}
public static void SelectiveColor(Bitmap bmp, Color lightColor, Color darkColor, int value)
public static void SelectiveColor(Bitmap bmp, Color lightColor, Color darkColor, int threshold)
{
using (UnsafeBitmap unsafeBitmap = new UnsafeBitmap(bmp, true))
{
for (int i = 0; i < unsafeBitmap.PixelCount; i++)
{
ColorBgra color = unsafeBitmap.GetPixel(i);
Color newColor = ColorHelpers.PerceivedBrightness(color.ToColor()) > value ? lightColor : darkColor;
Color newColor = ColorHelpers.PerceivedBrightness(color.ToColor()) > threshold ? lightColor : darkColor;
color.Red = newColor.R;
color.Green = newColor.G;
color.Blue = newColor.B;

View file

@ -24,14 +24,9 @@ You should have received a copy of the GNU General Public License
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShareX.ImageEffectsLib
{
@ -44,8 +39,8 @@ internal class SelectiveColor : ImageEffect
[DefaultValue(typeof(Color), "Black"), Editor(typeof(MyColorEditor), typeof(UITypeEditor)), TypeConverter(typeof(MyColorConverter))]
public Color DarkColor { get; set; }
[DefaultValue(120)]
public int Value { get; set; }
[DefaultValue(130)]
public int Threshold { get; set; }
public SelectiveColor()
{
@ -54,7 +49,7 @@ public SelectiveColor()
public override Image Apply(Image img)
{
ImageHelpers.SelectiveColor((Bitmap)img, LightColor, DarkColor, Value);
ImageHelpers.SelectiveColor((Bitmap)img, LightColor, DarkColor, Threshold);
return img;
}
}

View file

@ -25,13 +25,6 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ShareX.ScreenCaptureLib

View file

@ -190,4 +190,4 @@ public override string ToString()
}
}
}
}
}

View file

@ -25,10 +25,6 @@ You should have received a copy of the GNU General Public License
using ShareX.HelpersLib;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ShareX.UploadersLib
{