mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 06:23:24 -07:00
Make rotation work again
This commit is contained in:
parent
2bc74554ea
commit
b9e601b4ff
2 changed files with 31 additions and 1 deletions
|
@ -1824,5 +1824,27 @@ namespace Greenshot.Base.Core
|
|||
|
||||
return bitmap;
|
||||
}
|
||||
|
||||
/// <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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -207,7 +207,15 @@ namespace Greenshot.Editor.Drawing
|
|||
|
||||
private Image ComputeBitmap(int iconSize)
|
||||
{
|
||||
return EmojiRenderer.GetBitmap(Emoji, iconSize);
|
||||
var image = EmojiRenderer.GetBitmap(Emoji, iconSize);
|
||||
if (_rotationAngle != 0)
|
||||
{
|
||||
var newImage = image.Rotate(_rotationAngle);
|
||||
image.Dispose();
|
||||
return newImage;
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
private void ResetCachedBitmap()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue