mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -07:00
Revert to old rotation system
This commit is contained in:
parent
66703b5ae3
commit
4ff9f2a0ec
1 changed files with 13 additions and 19 deletions
|
@ -34,6 +34,7 @@ using Emoji.Wpf;
|
||||||
using Greenshot.Base.Interfaces.Drawing;
|
using Greenshot.Base.Interfaces.Drawing;
|
||||||
using Greenshot.Editor.Helpers;
|
using Greenshot.Editor.Helpers;
|
||||||
using Image = System.Drawing.Image;
|
using Image = System.Drawing.Image;
|
||||||
|
using Matrix = System.Drawing.Drawing2D.Matrix;
|
||||||
using Point = System.Drawing.Point;
|
using Point = System.Drawing.Point;
|
||||||
using Size = System.Windows.Size;
|
using Size = System.Windows.Size;
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ namespace Greenshot.Editor.Drawing
|
||||||
[NonSerialized] private bool _justCreated = true;
|
[NonSerialized] private bool _justCreated = true;
|
||||||
|
|
||||||
private string _emoji;
|
private string _emoji;
|
||||||
|
private int _rotationAngle;
|
||||||
|
|
||||||
public string Emoji
|
public string Emoji
|
||||||
{
|
{
|
||||||
|
@ -145,6 +147,14 @@ namespace Greenshot.Editor.Drawing
|
||||||
PropertyChanged += OnPropertyChanged;
|
PropertyChanged += OnPropertyChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Transform(Matrix matrix)
|
||||||
|
{
|
||||||
|
_rotationAngle += CalculateAngle(matrix);
|
||||||
|
_rotationAngle %= 360;
|
||||||
|
|
||||||
|
base.Transform(matrix);
|
||||||
|
}
|
||||||
|
|
||||||
private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void OnPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.PropertyName.Equals(nameof(Selected)))
|
if (e.PropertyName.Equals(nameof(Selected)))
|
||||||
|
@ -183,11 +193,10 @@ namespace Greenshot.Editor.Drawing
|
||||||
|
|
||||||
using var bitmap = BitmapFromSource(renderTargetBitmap);
|
using var bitmap = BitmapFromSource(renderTargetBitmap);
|
||||||
|
|
||||||
var rotationAngle = GetRotationAngle();
|
if (_rotationAngle != 0)
|
||||||
if (rotationAngle != 0)
|
|
||||||
{
|
{
|
||||||
using var newBitmap = RotateImage(bitmap, rotationAngle);
|
using var newBitmap = RotateImage(bitmap, _rotationAngle);
|
||||||
graphics.DrawImage(RotateImage(newBitmap, rotationAngle), Bounds);
|
graphics.DrawImage(newBitmap, Bounds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -195,21 +204,6 @@ namespace Greenshot.Editor.Drawing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetRotationAngle()
|
|
||||||
{
|
|
||||||
var rotationAngle = 0;
|
|
||||||
if (Width < 0)
|
|
||||||
{
|
|
||||||
rotationAngle = Height > 0 ? 90 : 180;
|
|
||||||
}
|
|
||||||
else if (Height < 0)
|
|
||||||
{
|
|
||||||
rotationAngle = 270;
|
|
||||||
}
|
|
||||||
|
|
||||||
return rotationAngle;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Bitmap BitmapFromSource(BitmapSource bitmapSource)
|
private Bitmap BitmapFromSource(BitmapSource bitmapSource)
|
||||||
{
|
{
|
||||||
var src = new FormatConvertedBitmap();
|
var src = new FormatConvertedBitmap();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue