diff --git a/Greenshot/Drawing/Surface.cs b/Greenshot/Drawing/Surface.cs index 0f2e876b0..db5b3c6b4 100644 --- a/Greenshot/Drawing/Surface.cs +++ b/Greenshot/Drawing/Surface.cs @@ -834,49 +834,6 @@ namespace Greenshot.Drawing { } return false; } - - /// - /// "Grow" the canvas with the specified pixels on the left, right, top and bottom. Using the backgroundColor. - /// - /// - /// - /// - /// - /// - public void GrowCanvas(Color backgroundColor, int left, int right, int top, int bottom) { - Bitmap newImage = ImageHelper.GrowCanvas((Bitmap)Image, backgroundColor, left, right, top, bottom); - // Make sure the elements move according to the offset the effect made the bitmap move - elements.MoveBy(left, top); - // Make undoable - MakeUndoable(new SurfaceBackgroundChangeMemento(this, new Point(left, top)), false); - SetImage(newImage, false); - Invalidate(); - if (surfaceSizeChanged != null) { - surfaceSizeChanged(this); - } - } - - /// - /// Resize bitmap - /// - /// - /// - /// - /// - /// - public void ResizeBitmap(bool lockAspectRatio, bool canvasUsedNewSize, Color backgroundColor, int newWidth, int newHeight) { - Point offset; - Bitmap newImage = ImageHelper.ResizeBitmap((Bitmap)Image, lockAspectRatio, canvasUsedNewSize, backgroundColor, newWidth, newHeight, out offset); - // Make sure the elements move according to the offset the effect made the bitmap move - elements.MoveBy(offset.X, offset.Y); - // Make undoable - MakeUndoable(new SurfaceBackgroundChangeMemento(this, offset), false); - SetImage(newImage, false); - Invalidate(); - if (surfaceSizeChanged != null) { - surfaceSizeChanged(this); - } - } /// /// A simple clear diff --git a/GreenshotPlugin/Core/Effects.cs b/GreenshotPlugin/Core/Effects.cs index 43aac5835..bbca4a9b5 100644 --- a/GreenshotPlugin/Core/Effects.cs +++ b/GreenshotPlugin/Core/Effects.cs @@ -183,4 +183,42 @@ namespace Greenshot.Core { return ImageHelper.ResizeBitmap(sourceBitmap, MaintainAspectRatio, Width, Height); } } + + /// + /// GrowEffect + /// + public class GrowEffect : IEffect { + public GrowEffect(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 Bitmap Apply(Bitmap sourceBitmap, out Point offsetChange) { + // Make sure the elements move according to the offset the effect made the bitmap move + offsetChange = new Point(Left, Top); + return ImageHelper.GrowCanvas(sourceBitmap, BackgroundColor, Left, Right, Top, Bottom); + } + } } \ No newline at end of file