mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 14:24:43 -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.Editor.Helpers;
|
||||
using Image = System.Drawing.Image;
|
||||
using Matrix = System.Drawing.Drawing2D.Matrix;
|
||||
using Point = System.Drawing.Point;
|
||||
using Size = System.Windows.Size;
|
||||
|
||||
|
@ -53,6 +54,7 @@ namespace Greenshot.Editor.Drawing
|
|||
[NonSerialized] private bool _justCreated = true;
|
||||
|
||||
private string _emoji;
|
||||
private int _rotationAngle;
|
||||
|
||||
public string Emoji
|
||||
{
|
||||
|
@ -145,6 +147,14 @@ namespace Greenshot.Editor.Drawing
|
|||
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)
|
||||
{
|
||||
if (e.PropertyName.Equals(nameof(Selected)))
|
||||
|
@ -183,11 +193,10 @@ namespace Greenshot.Editor.Drawing
|
|||
|
||||
using var bitmap = BitmapFromSource(renderTargetBitmap);
|
||||
|
||||
var rotationAngle = GetRotationAngle();
|
||||
if (rotationAngle != 0)
|
||||
if (_rotationAngle != 0)
|
||||
{
|
||||
using var newBitmap = RotateImage(bitmap, rotationAngle);
|
||||
graphics.DrawImage(RotateImage(newBitmap, rotationAngle), Bounds);
|
||||
using var newBitmap = RotateImage(bitmap, _rotationAngle);
|
||||
graphics.DrawImage(newBitmap, Bounds);
|
||||
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)
|
||||
{
|
||||
var src = new FormatConvertedBitmap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue