mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added simple blur drawing shape which renders blur only in output
This commit is contained in:
parent
133b5c3fe9
commit
7cfc326f79
6 changed files with 82 additions and 2 deletions
|
@ -162,7 +162,9 @@ public enum ShapeType
|
|||
[Description("Drawing: Line")]
|
||||
DrawingLine,
|
||||
[Description("Drawing: Arrow")]
|
||||
DrawingArrow
|
||||
DrawingArrow,
|
||||
[Description("Drawing: Blur")]
|
||||
DrawingBlur
|
||||
}
|
||||
|
||||
public enum RegionAnnotateMode
|
||||
|
|
|
@ -682,13 +682,14 @@ public override Image GetResultImage()
|
|||
{
|
||||
if (SurfaceImage != null && AreaManager.DrawingShapes.Length > 0)
|
||||
{
|
||||
using (Bitmap surfaceCopy = (Bitmap)SurfaceImage.Clone())
|
||||
using (Graphics g = Graphics.FromImage(SurfaceImage))
|
||||
{
|
||||
foreach (BaseDrawingShape shape in AreaManager.DrawingShapes)
|
||||
{
|
||||
if (shape != null)
|
||||
{
|
||||
shape.Draw(g);
|
||||
shape.DrawOutput(g, surfaceCopy);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -693,6 +693,9 @@ public BaseShape CreateRegionShape(Rectangle rect)
|
|||
case ShapeType.DrawingArrow:
|
||||
shape = new ArrowDrawingShape();
|
||||
break;
|
||||
case ShapeType.DrawingBlur:
|
||||
shape = new BlurDrawingShape();
|
||||
break;
|
||||
}
|
||||
|
||||
shape.Rectangle = rect;
|
||||
|
|
|
@ -41,6 +41,11 @@ public abstract class BaseDrawingShape : BaseShape
|
|||
|
||||
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);
|
||||
|
|
68
ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs
Normal file
68
ShareX.ScreenCaptureLib/Shapes/Drawing/BlurDrawingShape.cs
Normal file
|
@ -0,0 +1,68 @@
|
|||
#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 ShareX.HelpersLib;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
public class BlurDrawingShape : BaseDrawingShape
|
||||
{
|
||||
public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur;
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black)))
|
||||
{
|
||||
g.FillRectangle(brush, Rectangle);
|
||||
}
|
||||
|
||||
if (Rectangle.Width > 10 && Rectangle.Height > 10)
|
||||
{
|
||||
using (Font font = new Font("Verdana", 15, FontStyle.Bold))
|
||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||
{
|
||||
g.DrawString("Blur", font, Brushes.White, Rectangle, sf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void DrawOutput(Graphics g, Bitmap bmp)
|
||||
{
|
||||
using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle))
|
||||
{
|
||||
ImageHelpers.Blur(croppedImage, 20);
|
||||
|
||||
g.DrawImage(croppedImage, Rectangle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -83,6 +83,7 @@
|
|||
<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\Drawing\EllipseDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\LineDrawingShape.cs" />
|
||||
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
|
||||
|
|
Loading…
Reference in a new issue