mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -07:00
Update
This commit is contained in:
parent
076a8d23bd
commit
fde1539ac5
2 changed files with 30 additions and 65 deletions
|
@ -1804,29 +1804,6 @@ namespace Greenshot.Base.Core
|
|||
return returnImage;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Rotate the image
|
||||
/// </summary>
|
||||
/// <param name="image">Input image</param>
|
||||
/// <param name="rotationAngle">Angle in degrees</param>
|
||||
/// <returns>Rotated image</returns>
|
||||
public static Image Rotate(this Image image, float rotationAngle)
|
||||
{
|
||||
var bitmap = new Bitmap(image.Width, image.Height);
|
||||
|
||||
using var gfx = Graphics.FromImage(bitmap);
|
||||
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||
|
||||
gfx.TranslateTransform((float)bitmap.Width / 2, (float)bitmap.Height / 2);
|
||||
gfx.RotateTransform(rotationAngle);
|
||||
gfx.TranslateTransform(-(float)bitmap.Width / 2, -(float)bitmap.Height / 2);
|
||||
|
||||
gfx.DrawImage(image, new Point(0, 0));
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a bitmap from a WPF bitmap source
|
||||
/// </summary>
|
||||
|
|
|
@ -50,7 +50,6 @@ namespace Greenshot.Editor.Drawing
|
|||
[NonSerialized] private static ElementHost _emojiPickerHost;
|
||||
[NonSerialized] private static Picker _emojiPicker;
|
||||
|
||||
[NonSerialized] private System.Windows.Controls.Image _image;
|
||||
[NonSerialized] private bool _justCreated = true;
|
||||
[NonSerialized] private Image _cachedImage = null;
|
||||
|
||||
|
@ -63,10 +62,7 @@ namespace Greenshot.Editor.Drawing
|
|||
set
|
||||
{
|
||||
_emoji = value;
|
||||
if (_image != null)
|
||||
{
|
||||
global::Emoji.Wpf.Image.SetSource(_image, Emoji);
|
||||
}
|
||||
ResetCachedBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,10 +137,6 @@ namespace Greenshot.Editor.Drawing
|
|||
{
|
||||
CreateDefaultAdorners();
|
||||
|
||||
// Create WPF control that will be used to render the emoji
|
||||
_image = new System.Windows.Controls.Image();
|
||||
global::Emoji.Wpf.Image.SetSource(_image, Emoji);
|
||||
|
||||
PropertyChanged += OnPropertyChanged;
|
||||
}
|
||||
|
||||
|
@ -215,23 +207,19 @@ namespace Greenshot.Editor.Drawing
|
|||
|
||||
private Image ComputeBitmap(int iconSize)
|
||||
{
|
||||
_image.Measure(new Size(iconSize, iconSize));
|
||||
_image.Arrange(new Rect(0, 0, iconSize, iconSize));
|
||||
// Create WPF control that will be used to render the emoji
|
||||
var image = new System.Windows.Controls.Image();
|
||||
global::Emoji.Wpf.Image.SetSource(image, Emoji);
|
||||
|
||||
image.RenderTransformOrigin = new System.Windows.Point(0.5, 0.5);
|
||||
image.RenderTransform = new RotateTransform(_rotationAngle);
|
||||
image.Measure(new Size(iconSize, iconSize));
|
||||
image.Arrange(new Rect(0, 0, iconSize, iconSize));
|
||||
|
||||
var renderTargetBitmap = new RenderTargetBitmap(iconSize, iconSize, 96, 96, PixelFormats.Pbgra32);
|
||||
renderTargetBitmap.Render(_image);
|
||||
renderTargetBitmap.Render(image);
|
||||
|
||||
var bitmap = renderTargetBitmap.ToBitmap();
|
||||
|
||||
if (_rotationAngle != 0)
|
||||
{
|
||||
var newBitmap = bitmap.Rotate( _rotationAngle);
|
||||
bitmap.Dispose();
|
||||
|
||||
return newBitmap;
|
||||
}
|
||||
|
||||
return bitmap;
|
||||
return renderTargetBitmap.ToBitmap();
|
||||
}
|
||||
|
||||
private void ResetCachedBitmap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue