这看起来很简单,我在使用 Image.RotateFlip 方法之前已经完成了,但这是针对预定义的度数(取决于鼠标从其当前位置移动的距离。
这是我所拥有的,但我不知道为什么它没有应用(图像根本没有移动)
using (var g = Graphics.FromImage(pbProfile.Image))
{
g.TranslateTransform(pbProfile.Image.Width / 2f, pbProfile.Image.Height / 2f);
g.RotateTransform(Pixels);
}
pbProfile.Refresh();
我对任何和所有的建议都持开放态度,因为我的大脑现在已经炸了...
回答
虽然下面的答案在技术上是正确的,但我在这里找到了问题的实际解决方案:Draw manipulated graphic into another graphic这说明我不需要旋转我正在旋转的图像,而是我正在旋转的图形。
Bitmap bmp = new Bitmap(pbProfile.Image.Width, pbProfile.Image.Height);
using (var g = Graphics.FromImage(bmp))
{
g.TranslateTransform(bmp.Width / 2f, bmp.Height / 2f);
g.RotateTransform(Pixels);
g.DrawImage(pbProfile.Image, 0, 0);
}
pbProfile.Refresh();
最佳答案
您缺少 g.DrawImage()
调用
关于c# - 将图像旋转 n 度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23917887/