diff --git a/ShareX.ScreenCaptureLib/Enums.cs b/ShareX.ScreenCaptureLib/Enums.cs index 1568e68bc..75858f9cb 100644 --- a/ShareX.ScreenCaptureLib/Enums.cs +++ b/ShareX.ScreenCaptureLib/Enums.cs @@ -163,11 +163,11 @@ public enum ShapeType DrawingLine, [Description("Drawing: Arrow")] DrawingArrow, - [Description("Drawing: Blur")] + [Description("Effect: Blur")] DrawingBlur, - [Description("Drawing: Pixelate")] + [Description("Effect: Pixelate")] DrawingPixelate, - [Description("Drawing: Highlight")] + [Description("Effect: Highlight")] DrawingHighlight } diff --git a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs index f59d2bb85..bc7cd2fc1 100644 --- a/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs +++ b/ShareX.ScreenCaptureLib/Forms/RectangleRegionForm.cs @@ -204,6 +204,12 @@ protected override void Draw(Graphics g) } } + // Draw effect shapes + foreach (BaseEffectShape effectShape in AreaManager.EffectShapes) + { + effectShape.Draw(g); + } + // Draw drawing shapes foreach (BaseDrawingShape drawingShape in AreaManager.DrawingShapes) { @@ -691,16 +697,24 @@ protected override Image GetOutputImage() { Image img = base.GetOutputImage(); - if (AreaManager.DrawingShapes.Length > 0) + if (AreaManager.DrawingShapes.Length > 0 || AreaManager.EffectShapes.Length > 0) { using (Bitmap bmpCopy = new Bitmap(img)) using (Graphics g = Graphics.FromImage(img)) { + foreach (BaseEffectShape shape in AreaManager.EffectShapes) + { + if (shape != null) + { + shape.DrawFinal(g, bmpCopy); + } + } + foreach (BaseDrawingShape shape in AreaManager.DrawingShapes) { if (shape != null) { - shape.DrawOutput(g, bmpCopy); + shape.Draw(g); } } } diff --git a/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs b/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs index 3d41648f9..c50a12ef6 100644 --- a/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs +++ b/ShareX.ScreenCaptureLib/RegionHelpers/ShapeManager.cs @@ -84,6 +84,14 @@ public BaseDrawingShape[] DrawingShapes } } + public BaseEffectShape[] EffectShapes + { + get + { + return Shapes.OfType().ToArray(); + } + } + public BaseShape[] ValidRegions { get @@ -815,13 +823,13 @@ public BaseShape CreateRegionShape(Rectangle rect) shape = new ArrowDrawingShape(); break; case ShapeType.DrawingBlur: - shape = new BlurDrawingShape(); + shape = new BlurEffectShape(); break; case ShapeType.DrawingPixelate: - shape = new PixelateDrawingShape(); + shape = new PixelateEffectShape(); break; case ShapeType.DrawingHighlight: - shape = new HighlightDrawingShape(); + shape = new HighlightEffectShape(); break; } @@ -854,19 +862,19 @@ private void UpdateShape(BaseShape shape) IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape; roundedRectangleShape.Radius = config.ShapeRoundedRectangleRadius; } - else if (shape is BlurDrawingShape) + else if (shape is BlurEffectShape) { - BlurDrawingShape blurDrawingShape = (BlurDrawingShape)shape; + BlurEffectShape blurDrawingShape = (BlurEffectShape)shape; blurDrawingShape.BlurRadius = config.ShapeBlurRadius; } - else if (shape is PixelateDrawingShape) + else if (shape is PixelateEffectShape) { - PixelateDrawingShape pixelateDrawingShape = (PixelateDrawingShape)shape; + PixelateEffectShape pixelateDrawingShape = (PixelateEffectShape)shape; pixelateDrawingShape.PixelSize = config.ShapePixelateSize; } - else if (shape is HighlightDrawingShape) + else if (shape is HighlightEffectShape) { - HighlightDrawingShape highlightDrawingShape = (HighlightDrawingShape)shape; + HighlightEffectShape highlightDrawingShape = (HighlightEffectShape)shape; highlightDrawingShape.HighlightColor = config.ShapeHighlightColor; } } diff --git a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs index b5801b799..cf5410cfe 100644 --- a/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/BaseShape.cs @@ -78,7 +78,10 @@ public BaseShape(Rectangle rect) Rectangle = rect; } - public abstract void AddShapePath(GraphicsPath gp, Rectangle rect); + public virtual void AddShapePath(GraphicsPath gp, Rectangle rect) + { + gp.AddRectangle(rect); + } public void AddShapePath(GraphicsPath gp) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs index 54bcfccaf..f8fe6e52d 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Drawing/BaseDrawingShape.cs @@ -40,15 +40,5 @@ public abstract class BaseDrawingShape : BaseShape public int BorderSize { get; set; } public abstract void Draw(Graphics g); - - public virtual void DrawOutput(Graphics g, Bitmap bmp) - { - Draw(g); - } - - public override void AddShapePath(GraphicsPath gp, Rectangle rect) - { - gp.AddRectangle(rect); - } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs new file mode 100644 index 000000000..7fa8a45c6 --- /dev/null +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs @@ -0,0 +1,43 @@ +#region License Information (GPL v3) + +/* + ShareX - A program that allows you to take screenshots and share any file type + Copyright (c) 2007-2016 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 . +*/ + +#endregion License Information (GPL v3) + +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; + +namespace ShareX.ScreenCaptureLib +{ + public abstract class BaseEffectShape : BaseShape + { + public abstract void Draw(Graphics g); + + public virtual void DrawFinal(Graphics g, Bitmap bmp) + { + Draw(g); + } + } +} \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs similarity index 95% rename from ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs rename to ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs index fa4ffe557..94656e335 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/BlurEffectShape.cs @@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License namespace ShareX.ScreenCaptureLib { - public class BlurDrawingShape : BaseDrawingShape + public class BlurEffectShape : BaseEffectShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur; @@ -65,7 +65,7 @@ public override void Draw(Graphics g) } } - public override void DrawOutput(Graphics g, Bitmap bmp) + public override void DrawFinal(Graphics g, Bitmap bmp) { if (BlurRadius > 1) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/HighlightDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs similarity index 95% rename from ShareX.ScreenCaptureLib/Shapes/Drawing/HighlightDrawingShape.cs rename to ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs index 9c10c73fb..5bdfaa6a0 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/HighlightDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/HighlightEffectShape.cs @@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License namespace ShareX.ScreenCaptureLib { - public class HighlightDrawingShape : BaseDrawingShape + public class HighlightEffectShape : BaseEffectShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingHighlight; @@ -62,7 +62,7 @@ public override void Draw(Graphics g) } } - public override void DrawOutput(Graphics g, Bitmap bmp) + public override void DrawFinal(Graphics g, Bitmap bmp) { using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs similarity index 95% rename from ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs rename to ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs index 987d0228d..ae61b4e7a 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Drawing/PixelateDrawingShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Effect/PixelateEffectShape.cs @@ -34,7 +34,7 @@ You should have received a copy of the GNU General Public License namespace ShareX.ScreenCaptureLib { - public class PixelateDrawingShape : BaseDrawingShape + public class PixelateEffectShape : BaseEffectShape { public override ShapeType ShapeType { get; } = ShapeType.DrawingPixelate; @@ -65,7 +65,7 @@ public override void Draw(Graphics g) } } - public override void DrawOutput(Graphics g, Bitmap bmp) + public override void DrawFinal(Graphics g, Bitmap bmp) { if (PixelSize > 1) { diff --git a/ShareX.ScreenCaptureLib/Shapes/Region/RectangleRegionShape.cs b/ShareX.ScreenCaptureLib/Shapes/Region/RectangleRegionShape.cs index 0c47036c2..c413762ad 100644 --- a/ShareX.ScreenCaptureLib/Shapes/Region/RectangleRegionShape.cs +++ b/ShareX.ScreenCaptureLib/Shapes/Region/RectangleRegionShape.cs @@ -35,10 +35,5 @@ namespace ShareX.ScreenCaptureLib public class RectangleRegionShape : BaseRegionShape { public override ShapeType ShapeType { get; } = ShapeType.RegionRectangle; - - public override void AddShapePath(GraphicsPath gp, Rectangle rect) - { - gp.AddRectangle(rect); - } } } \ No newline at end of file diff --git a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj index 1d4bf17b3..3d35d76b4 100644 --- a/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj +++ b/ShareX.ScreenCaptureLib/ShareX.ScreenCaptureLib.csproj @@ -83,13 +83,14 @@ - + - + - + +