From da9077b6c1d999e5424fd6ea7cddb8d5b5a1df3e Mon Sep 17 00:00:00 2001 From: Jaex Date: Fri, 6 May 2016 20:24:39 +0300 Subject: [PATCH] Remember blur radius and pixel size --- .../RegionHelpers/AreaManager.cs | 16 +++++++++++--- .../Shapes/Drawing/BlurDrawingShape.cs | 4 +++- .../Shapes/Drawing/PixelateDrawingShape.cs | 4 +++- ShareX.ScreenCaptureLib/SurfaceOptions.cs | 21 +++++++------------ 4 files changed, 26 insertions(+), 19 deletions(-) diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs b/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs index 757787f83..0557ee225 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/AreaManager.cs @@ -425,7 +425,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e) { case ShapeType.RegionRoundedRectangle: case ShapeType.DrawingRoundedRectangle: - config.RoundedRectangleRadius += RoundedRectangleRadiusIncrement; + config.ShapeRoundedRectangleRadius += RoundedRectangleRadiusIncrement; UpdateShape(); break; } @@ -435,7 +435,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e) { case ShapeType.RegionRoundedRectangle: case ShapeType.DrawingRoundedRectangle: - config.RoundedRectangleRadius = Math.Max(0, config.RoundedRectangleRadius - RoundedRectangleRadiusIncrement); + config.ShapeRoundedRectangleRadius = Math.Max(0, config.ShapeRoundedRectangleRadius - RoundedRectangleRadiusIncrement); UpdateShape(); break; } @@ -728,7 +728,17 @@ private void UpdateShape(BaseShape shape) if (shape is IRoundedRectangleShape) { IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape; - roundedRectangleShape.Radius = config.RoundedRectangleRadius; + roundedRectangleShape.Radius = config.ShapeRoundedRectangleRadius; + } + else if (shape is BlurDrawingShape) + { + BlurDrawingShape blurDrawingShape = (BlurDrawingShape)shape; + blurDrawingShape.BlurRadius = config.ShapeBlurRadius; + } + else if (shape is PixelateDrawingShape) + { + PixelateDrawingShape pixelateDrawingShape = (PixelateDrawingShape)shape; + pixelateDrawingShape.PixelSize = config.ShapePixelSize; } } } diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs index 1e6aa2a09..3f1fbb41c 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs @@ -38,6 +38,8 @@ public class BlurDrawingShape : BaseDrawingShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur; + public int BlurRadius { get; set; } + public override void Draw(Graphics g) { using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black))) @@ -59,7 +61,7 @@ public override void DrawOutput(Graphics g, Bitmap bmp) { using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) { - ImageHelpers.Blur(croppedImage, 20); + ImageHelpers.Blur(croppedImage, BlurRadius); g.DrawImage(croppedImage, Rectangle); } diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs index b531632fe..e7b0268dc 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs @@ -38,6 +38,8 @@ public class PixelateDrawingShape : BaseDrawingShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur; + public int PixelSize { get; set; } + public override void Draw(Graphics g) { using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black))) @@ -58,7 +60,7 @@ public override void Draw(Graphics g) public override void DrawOutput(Graphics g, Bitmap bmp) { using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) - using (Bitmap pixelatedImage = ImageHelpers.Pixelate(croppedImage, 7)) + using (Bitmap pixelatedImage = ImageHelpers.Pixelate(croppedImage, PixelSize)) { g.DrawImage(pixelatedImage, Rectangle); } diff --git a/ShareX.ScreenCaptureLib/SurfaceOptions.cs b/ShareX.ScreenCaptureLib/SurfaceOptions.cs index 7fd45b0e4..5061facd3 100644 --- a/ShareX.ScreenCaptureLib/SurfaceOptions.cs +++ b/ShareX.ScreenCaptureLib/SurfaceOptions.cs @@ -98,20 +98,13 @@ public class SurfaceOptions [Description("How close to a snap size you must be for it to snap.")] public List SnapSizes { get; set; } - [DefaultValue(ShapeType.RegionRectangle)] - public ShapeType CurrentShapeType { get; set; } = ShapeType.RegionRectangle; - - [DefaultValue(typeof(Color), "Red")] - public Color ShapeBorderColor { get; set; } = Color.Red; - - [DefaultValue(2)] - public int ShapeBorderSize { get; set; } = 2; - - [DefaultValue(typeof(Color), "0, 0, 0, 0")] - public Color ShapeFillColor { get; set; } = Color.FromArgb(0, 0, 0, 0); - - [DefaultValue(15)] - public float RoundedRectangleRadius { get; set; } = 15; + public ShapeType CurrentShapeType = ShapeType.RegionRectangle; + public Color ShapeBorderColor = Color.Red; + public int ShapeBorderSize = 2; + public Color ShapeFillColor = Color.FromArgb(0, 0, 0, 0); + public float ShapeRoundedRectangleRadius = 15; + public int ShapeBlurRadius = 15; + public int ShapePixelSize = 7; public SurfaceOptions() {