mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Added BaseEffectShape
This commit is contained in:
parent
d1ec0b8ae6
commit
c5e601a34d
11 changed files with 93 additions and 39 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,6 +84,14 @@ public BaseDrawingShape[] DrawingShapes
|
|||
}
|
||||
}
|
||||
|
||||
public BaseEffectShape[] EffectShapes
|
||||
{
|
||||
get
|
||||
{
|
||||
return Shapes.OfType<BaseEffectShape>().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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
43
ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs
Normal file
43
ShareX.ScreenCaptureLib/Shapes/Effect/BaseEffectShape.cs
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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)
|
||||
{
|
|
@ -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))
|
||||
{
|
|
@ -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)
|
||||
{
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,13 +83,14 @@
|
|||
<Compile Include="Shapes\BaseShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\BaseDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\BlurDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Effect\BlurEffectShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\EllipseDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\HighlightDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Effect\HighlightEffectShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\LineDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\PixelateDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Effect\PixelateEffectShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\RoundedRectangleDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Effect\BaseEffectShape.cs" />
|
||||
<Compile Include="Shapes\IRoundedRectangleShape.cs" />
|
||||
<Compile Include="Shapes\Region\EllipseRegionShape.cs" />
|
||||
<Compile Include="Shapes\Region\RectangleRegionShape.cs" />
|
||||
|
|
Loading…
Reference in a new issue