Moved unused effect from Surface internal to IEffect implementation

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2383 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-12-12 16:43:16 +00:00
commit e7ab5f5677
2 changed files with 38 additions and 43 deletions

View file

@ -835,49 +835,6 @@ namespace Greenshot.Drawing {
return false; return false;
} }
/// <summary>
/// "Grow" the canvas with the specified pixels on the left, right, top and bottom. Using the backgroundColor.
/// </summary>
/// <param name="backgroundColor"></param>
/// <param name="left"></param>
/// <param name="right"></param>
/// <param name="top"></param>
/// <param name="bottom"></param>
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);
}
}
/// <summary>
/// Resize bitmap
/// </summary>
/// <param name="backgroundColor"></param>
/// <param name="left"></param>
/// <param name="right"></param>
/// <param name="top"></param>
/// <param name="bottom"></param>
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);
}
}
/// <summary> /// <summary>
/// A simple clear /// A simple clear
/// </summary> /// </summary>

View file

@ -183,4 +183,42 @@ namespace Greenshot.Core {
return ImageHelper.ResizeBitmap(sourceBitmap, MaintainAspectRatio, Width, Height); return ImageHelper.ResizeBitmap(sourceBitmap, MaintainAspectRatio, Width, Height);
} }
} }
/// <summary>
/// GrowEffect
/// </summary>
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);
}
}
} }