mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
Code quality changes
This commit is contained in:
parent
f07ed83722
commit
610f45d082
189 changed files with 4609 additions and 5203 deletions
57
GreenshotPlugin/Effects/AdjustEffect.cs
Normal file
57
GreenshotPlugin/Effects/AdjustEffect.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// AdjustEffect
|
||||
/// </summary>
|
||||
public class AdjustEffect : IEffect {
|
||||
public AdjustEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public float Contrast {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public float Brightness {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public float Gamma {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
Contrast = 1f;
|
||||
Brightness = 1f;
|
||||
Gamma = 1f;
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.Adjust(sourceImage, Brightness, Contrast, Gamma);
|
||||
}
|
||||
}
|
||||
}
|
51
GreenshotPlugin/Effects/BorderEffect.cs
Normal file
51
GreenshotPlugin/Effects/BorderEffect.cs
Normal file
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// BorderEffect
|
||||
/// </summary>
|
||||
public class BorderEffect : IEffect {
|
||||
public BorderEffect() {
|
||||
Reset();
|
||||
}
|
||||
public Color Color {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Width {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
Width = 2;
|
||||
Color = Color.Black;
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateBorder(sourceImage, Width, Color, sourceImage.PixelFormat, matrix);
|
||||
}
|
||||
}
|
||||
}
|
64
GreenshotPlugin/Effects/DropShadowEffect.cs
Normal file
64
GreenshotPlugin/Effects/DropShadowEffect.cs
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects {
|
||||
/// <summary>
|
||||
/// DropShadowEffect
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(EffectConverter))]
|
||||
public class DropShadowEffect : IEffect {
|
||||
public DropShadowEffect() {
|
||||
Reset();
|
||||
}
|
||||
|
||||
public float Darkness {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public int ShadowSize {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Point ShadowOffset {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public virtual void Reset() {
|
||||
Darkness = 0.6f;
|
||||
ShadowSize = 7;
|
||||
ShadowOffset = new Point(-1, -1);
|
||||
}
|
||||
|
||||
public virtual Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateShadow(sourceImage, Darkness, ShadowSize, ShadowOffset, matrix, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
}
|
||||
}
|
39
GreenshotPlugin/Effects/GrayscaleEffect.cs
Normal file
39
GreenshotPlugin/Effects/GrayscaleEffect.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// GrayscaleEffect
|
||||
/// </summary>
|
||||
public class GrayscaleEffect : IEffect {
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateGrayscale(sourceImage);
|
||||
}
|
||||
public void Reset() {
|
||||
// No settings to reset
|
||||
}
|
||||
}
|
||||
}
|
45
GreenshotPlugin/Effects/IEffect.cs
Normal file
45
GreenshotPlugin/Effects/IEffect.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface to describe an effect
|
||||
/// </summary>
|
||||
public interface IEffect {
|
||||
/// <summary>
|
||||
/// Apply this IEffect to the supplied sourceImage.
|
||||
/// In the process of applying the supplied matrix will be modified to represent the changes.
|
||||
/// </summary>
|
||||
/// <param name="sourceImage">Image to apply the effect to</param>
|
||||
/// <param name="matrix">Matrix with the modifications like rotate, translate etc. this can be used to calculate the new location of elements on a canvas</param>
|
||||
/// <returns>new image with applied effect</returns>
|
||||
Image Apply(Image sourceImage, Matrix matrix);
|
||||
|
||||
/// <summary>
|
||||
/// Reset all values to their defaults
|
||||
/// </summary>
|
||||
void Reset();
|
||||
}
|
||||
}
|
39
GreenshotPlugin/Effects/InvertEffect.cs
Normal file
39
GreenshotPlugin/Effects/InvertEffect.cs
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// InvertEffect
|
||||
/// </summary>
|
||||
public class InvertEffect : IEffect {
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateNegative(sourceImage);
|
||||
}
|
||||
public void Reset() {
|
||||
// No settings to reset
|
||||
}
|
||||
}
|
||||
}
|
44
GreenshotPlugin/Effects/MonochromeEffect.cs
Normal file
44
GreenshotPlugin/Effects/MonochromeEffect.cs
Normal file
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// MonochromeEffect
|
||||
/// </summary>
|
||||
public class MonochromeEffect : IEffect {
|
||||
private readonly byte _threshold;
|
||||
/// <param name="threshold">Threshold for monochrome filter (0 - 255), lower value means less black</param>
|
||||
public MonochromeEffect(byte threshold) {
|
||||
_threshold = threshold;
|
||||
}
|
||||
public void Reset() {
|
||||
// TODO: Modify the threshold to have a default, which is reset here
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.CreateMonochrome(sourceImage, _threshold);
|
||||
}
|
||||
}
|
||||
}
|
60
GreenshotPlugin/Effects/ReduceColorsEffect.cs
Normal file
60
GreenshotPlugin/Effects/ReduceColorsEffect.cs
Normal file
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
using log4net;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// ReduceColorsEffect
|
||||
/// </summary>
|
||||
public class ReduceColorsEffect : IEffect {
|
||||
private static readonly ILog Log = LogManager.GetLogger(typeof(ReduceColorsEffect));
|
||||
public ReduceColorsEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public int Colors {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
Colors = 256;
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
using (WuQuantizer quantizer = new WuQuantizer((Bitmap)sourceImage)) {
|
||||
int colorCount = quantizer.GetColorCount();
|
||||
if (colorCount > Colors) {
|
||||
try {
|
||||
return quantizer.GetQuantizedImage(Colors);
|
||||
} catch (Exception e) {
|
||||
Log.Warn("Error occurred while Quantizing the image, ignoring and using original. Error: ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
66
GreenshotPlugin/Effects/ResizeCanvasEffect.cs
Normal file
66
GreenshotPlugin/Effects/ResizeCanvasEffect.cs
Normal file
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// ResizeCanvasEffect
|
||||
/// </summary>
|
||||
public class ResizeCanvasEffect : IEffect {
|
||||
public ResizeCanvasEffect(int left, int right, int top, int bottom) {
|
||||
Left = left;
|
||||
Right = right;
|
||||
Top = top;
|
||||
Bottom = bottom;
|
||||
BackgroundColor = Color.Empty; // Uses the default background color depending on the format
|
||||
}
|
||||
public int Left {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Right {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Top {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Bottom {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public Color BackgroundColor {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
// values don't have a default value
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.ResizeCanvas(sourceImage, BackgroundColor, Left, Right, Top, Bottom, matrix);
|
||||
}
|
||||
}
|
||||
}
|
56
GreenshotPlugin/Effects/ResizeEffect.cs
Normal file
56
GreenshotPlugin/Effects/ResizeEffect.cs
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// ResizeEffect
|
||||
/// </summary>
|
||||
public class ResizeEffect : IEffect {
|
||||
public ResizeEffect(int width, int height, bool maintainAspectRatio) {
|
||||
Width = width;
|
||||
Height = height;
|
||||
MaintainAspectRatio = maintainAspectRatio;
|
||||
}
|
||||
public int Width {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int Height {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool MaintainAspectRatio {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
// values don't have a default value
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
return ImageHelper.ResizeImage(sourceImage, MaintainAspectRatio, Width, Height, matrix);
|
||||
}
|
||||
}
|
||||
}
|
59
GreenshotPlugin/Effects/RotateEffect.cs
Normal file
59
GreenshotPlugin/Effects/RotateEffect.cs
Normal file
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// RotateEffect
|
||||
/// </summary>
|
||||
public class RotateEffect : IEffect {
|
||||
public RotateEffect(int angle) {
|
||||
Angle = angle;
|
||||
}
|
||||
public int Angle {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public void Reset() {
|
||||
// Angle doesn't have a default value
|
||||
}
|
||||
public Image Apply(Image sourceImage, Matrix matrix) {
|
||||
RotateFlipType flipType;
|
||||
if (Angle == 90) {
|
||||
matrix.Rotate(90, MatrixOrder.Append);
|
||||
matrix.Translate(sourceImage.Height, 0, MatrixOrder.Append);
|
||||
flipType = RotateFlipType.Rotate90FlipNone;
|
||||
} else if (Angle == -90 || Angle == 270) {
|
||||
flipType = RotateFlipType.Rotate270FlipNone;
|
||||
matrix.Rotate(-90, MatrixOrder.Append);
|
||||
matrix.Translate(0, sourceImage.Width, MatrixOrder.Append);
|
||||
} else {
|
||||
throw new NotSupportedException("Currently only an angle of 90 or -90 (270) is supported.");
|
||||
}
|
||||
return ImageHelper.RotateFlip(sourceImage, flipType);
|
||||
}
|
||||
}
|
||||
}
|
80
GreenshotPlugin/Effects/TornEdgeEffect.cs
Normal file
80
GreenshotPlugin/Effects/TornEdgeEffect.cs
Normal file
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* Greenshot - a free and open source screenshot tool
|
||||
* Copyright (C) 2007-2016 Thomas Braun, Jens Klingen, Robin Krom
|
||||
*
|
||||
* For more information see: http://getgreenshot.org/
|
||||
* The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||
*
|
||||
* 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 1 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, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using Greenshot.Core;
|
||||
using GreenshotPlugin.Core;
|
||||
|
||||
namespace GreenshotPlugin.Effects
|
||||
{
|
||||
/// <summary>
|
||||
/// TornEdgeEffect extends on DropShadowEffect
|
||||
/// </summary>
|
||||
[TypeConverter(typeof(EffectConverter))]
|
||||
public sealed class TornEdgeEffect : DropShadowEffect {
|
||||
public TornEdgeEffect()
|
||||
{
|
||||
Reset();
|
||||
}
|
||||
public int ToothHeight {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int HorizontalToothRange {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public int VerticalToothRange {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool[] Edges {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
public bool GenerateShadow {
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public override void Reset() {
|
||||
base.Reset();
|
||||
ShadowSize = 7;
|
||||
ToothHeight = 12;
|
||||
HorizontalToothRange = 20;
|
||||
VerticalToothRange = 20;
|
||||
Edges = new[] { true, true, true, true };
|
||||
GenerateShadow = true;
|
||||
}
|
||||
public override Image Apply(Image sourceImage, Matrix matrix) {
|
||||
Image tmpTornImage = ImageHelper.CreateTornEdge(sourceImage, ToothHeight, HorizontalToothRange, VerticalToothRange, Edges);
|
||||
if (GenerateShadow) {
|
||||
using (tmpTornImage) {
|
||||
return ImageHelper.CreateShadow(tmpTornImage, Darkness, ShadowSize, ShadowOffset, matrix, PixelFormat.Format32bppArgb);
|
||||
}
|
||||
}
|
||||
return tmpTornImage;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue