Code refactor

This commit is contained in:
Jaex 2020-09-15 03:36:49 +03:00
parent 18ed2567b4
commit ea695ab926
4 changed files with 38 additions and 8 deletions

View file

@ -1390,7 +1390,7 @@ public static void ColorDepth(Bitmap bmp, int bitsPerChannel = 4)
byte Remap(byte color, double interval)
{
return (byte) Math.Round((Math.Round(color / interval) * interval));
return (byte)Math.Round(Math.Round(color / interval) * interval);
}
using (UnsafeBitmap unsafeBitmap = new UnsafeBitmap(bmp, true))

View file

@ -1,19 +1,50 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2020 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using ShareX.HelpersLib;
using System.ComponentModel;
using System.Drawing;
using ShareX.HelpersLib;
namespace ShareX.ImageEffectsLib
{
[Description("Color depth")]
internal class ColorDepth : ImageEffect
{
private int _bitsPerChannel;
private int bitsPerChannel;
[DefaultValue(4)]
public int BitsPerChannel
{
get => this._bitsPerChannel;
set => this._bitsPerChannel = value.Max(1).Min(8);
get
{
return bitsPerChannel;
}
set
{
bitsPerChannel = MathHelpers.Clamp(value, 1, 8);
}
}
public ColorDepth()
@ -23,7 +54,7 @@ public ColorDepth()
public override Bitmap Apply(Bitmap bmp)
{
ImageHelpers.ColorDepth(bmp, this.BitsPerChannel);
ImageHelpers.ColorDepth(bmp, BitsPerChannel);
return bmp;
}
}

View file

@ -174,7 +174,7 @@ private bool StartEncoding()
private Task<bool> StartEncodingAsync()
{
return Task.Run(() => StartEncoding());
return Task.Run(StartEncoding);
}
private void Manager_EncodeProgressChanged(float percentage)

View file

@ -34,7 +34,6 @@
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>