Code refactor

This commit is contained in:
Jaex 2020-07-03 14:18:47 +03:00
parent c6e99f495a
commit 423b4d6860
2 changed files with 12 additions and 9 deletions

View file

@ -30,19 +30,20 @@
namespace ShareX.ImageEffectsLib
{
[Description("RGB Split")]
[Description("RGB split")]
internal class RGBSplit : ImageEffect
{
[DefaultValue(typeof(Point), "5, 0")]
public Point OffsetRed { get; set; }
[DefaultValue(typeof(Point), "-5, 0")]
public Point OffsetRed { get; set; } = new Point(-5, 0);
[DefaultValue(typeof(Point), "0, 0")]
public Point OffsetGreen { get; set; }
[DefaultValue(typeof(Point), "-5, 0")]
public Point OffsetBlue { get; set; }
[DefaultValue(typeof(Point), "5, 0")]
public Point OffsetBlue { get; set; } = new Point(5, 0);
public override Bitmap Apply(Bitmap bmp)
{
Bitmap bmpResult = bmp.CreateEmptyBitmap();
using (UnsafeBitmap source = new UnsafeBitmap(bmp, true, ImageLockMode.ReadOnly))
using (UnsafeBitmap dest = new UnsafeBitmap(bmpResult, true, ImageLockMode.WriteOnly))
{
@ -57,13 +58,15 @@ public override Bitmap Apply(Bitmap bmp)
byte colorR_alpha = colorR.Alpha;
byte colorG_alpha = colorG.Alpha;
byte colorB_alpha = colorB.Alpha;
byte colorA = (byte)((colorR_alpha / 3 + colorG_alpha / 3 + colorB_alpha / 3));
byte colorA = (byte)(colorR_alpha / 3 + colorG_alpha / 3 + colorB_alpha / 3);
ColorBgra shiftedcolor = new ColorBgra((byte)(colorB.Blue * colorB_alpha / 255), (byte)(colorG.Green * colorG_alpha / 255), (byte)(colorR.Red * colorR_alpha / 255), colorA);
dest.SetPixel(x, y, shiftedcolor);
ColorBgra shiftedColor = new ColorBgra((byte)(colorB.Blue * colorB_alpha / 255), (byte)(colorG.Green * colorG_alpha / 255),
(byte)(colorR.Red * colorR_alpha / 255), colorA);
dest.SetPixel(x, y, shiftedColor);
}
}
}
return bmpResult;
}
}

View file

@ -162,8 +162,8 @@ private void AddAllEffectsToContextMenu()
typeof(MeanRemoval),
typeof(Outline),
typeof(Pixelate),
typeof(RGBSplit),
typeof(Reflection),
typeof(RGBSplit),
typeof(Shadow),
typeof(Sharpen),
typeof(Slice),