Added initial code for rotating

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@1676 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-02-27 06:29:32 +00:00
parent 70103d745f
commit aeb7e5d78e
2 changed files with 38 additions and 0 deletions

View file

@ -52,6 +52,14 @@ namespace Greenshot.Drawing {
}
}
public List<IDrawableContainer> AsIDrawableContainerList() {
List<IDrawableContainer> interfaceList = new List<IDrawableContainer>();
foreach(IDrawableContainer container in this) {
interfaceList.Add(container);
}
return interfaceList;
}
/// <summary>
/// Gets or sets the selection status of the elements.
/// If several elements are in the list, true is only returned when all elements are selected.

View file

@ -571,6 +571,36 @@ namespace Greenshot.Drawing {
case Effects.Grayscale:
newImage = ImageHelper.CreateGrayscale((Bitmap)Image);
break;
case Effects.Rotate270:
MakeUndoable(new DrawableContainerBoundsChangeMemento(elements.AsIDrawableContainerList()), false);
foreach(DrawableContainer drawableContainer in elements) {
int x1 = drawableContainer.Bounds.X - (Width >> 1);
int y1 = (-drawableContainer.Bounds.Y) + (Height >> 1);
int rotatedX1 = y1;
int rotatedY1 = -x1;
int newX1 = y1 + (Height >> 1);
int newY1 = -x1 - (Width >> 1);
int x2 = (drawableContainer.Bounds.X+drawableContainer.Bounds.Width) - (Width >> 1);
int y2 = (-(drawableContainer.Bounds.Y+drawableContainer.Bounds.Height)) + (Height >> 1);
int rotatedX2 = y2;
int rotatedY2 = -x2;
int newX2 = y2 + (Height >> 1);
int newY2 = -x2 - (Width >> 1);
int newWidth = newX2 - newX1;
int newHeight = newY2 - newY1;
RectangleF newRectangle = new RectangleF(
newX1,
newY1,
newWidth,
newHeight
);
LOG.DebugFormat("Bounds before {0}, bounds after {1}", drawableContainer.Bounds, newRectangle);
drawableContainer.ApplyBounds(newRectangle);
}
newImage = ImageHelper.RotateFlip((Bitmap)Image, RotateFlipType.Rotate270FlipNone);
break;
}
if (newImage != null) {