Improved calculating the new location, when rotating. Still not correct, but it is better :)

This commit is contained in:
RKrom 2014-05-31 15:55:48 +02:00
commit ee911e3cdf
2 changed files with 11 additions and 17 deletions

View file

@ -18,19 +18,20 @@
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
using System;
using System.Collections.Generic; using Greenshot.Configuration;
using System.ComponentModel;
using System.Drawing;
using System.Threading;
using Greenshot.Drawing.Fields; using Greenshot.Drawing.Fields;
using Greenshot.Memento; using Greenshot.Memento;
using Greenshot.Plugin; using Greenshot.Plugin;
using Greenshot.Plugin.Drawing; using Greenshot.Plugin.Drawing;
using System.Windows.Forms;
using GreenshotPlugin.Core; using GreenshotPlugin.Core;
using Greenshot.Configuration; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Threading;
using System.Windows.Forms;
namespace Greenshot.Drawing { namespace Greenshot.Drawing {
/// <summary> /// <summary>
@ -134,12 +135,7 @@ namespace Greenshot.Drawing {
bool modified = false; bool modified = false;
Invalidate(); Invalidate();
foreach (var dc in this) { foreach (var dc in this) {
//Point[] points = new Point[] { new Point(rectangle.Left, rectangle.Top), new Point(rectangle.Right, rectangle.Bottom) }; Point[] location = { dc.Location };
//matrix.TransformPoints(points);
// Return that as a rectangle
//new Rectangle(points[0], new Size(points[0].X - points[1].X, points[0].Y - points[1].Y));
Point[] location = new Point[] { dc.Location };
matrix.TransformPoints(location); matrix.TransformPoints(location);
dc.Left = location[0].X; dc.Left = location[0].X;

View file

@ -215,14 +215,12 @@ namespace Greenshot.Core {
RotateFlipType flipType; RotateFlipType flipType;
if (Angle == 90) { if (Angle == 90) {
matrix.Rotate(90); matrix.Rotate(90);
matrix.Translate(-sourceImage.Height, 0); matrix.Translate(0, -sourceImage.Height);
//matrix.RotateAt(90, new Point(sourceImage.Width / 2, sourceImage.Height / 2));
flipType = RotateFlipType.Rotate90FlipNone; flipType = RotateFlipType.Rotate90FlipNone;
} else if (Angle == -90 || Angle == 270) { } else if (Angle == -90 || Angle == 270) {
flipType = RotateFlipType.Rotate270FlipNone; flipType = RotateFlipType.Rotate270FlipNone;
matrix.Rotate(-90); matrix.Rotate(-90);
//matrix.RotateAt(-90, new Point(sourceImage.Width / 2, sourceImage.Height / 2)); matrix.Translate(-sourceImage.Width, 0);
matrix.Translate(0, -sourceImage.Width);
} else { } else {
throw new NotSupportedException("Currently only an angle of 90 or -90 (270) is supported."); throw new NotSupportedException("Currently only an angle of 90 or -90 (270) is supported.");
} }