【发布时间】:2018-12-22 14:37:39
【问题描述】:
我编写了一个旋转图像的函数,以使其快速(这对于旋转数百张照片非常重要)我没有在每次旋转图像时都制作新的位图。但是,这导致旧照片出现在背景中,如果不创建会减慢一切的新位图,我怎么能解决这个问题!
public static Image RotateImage(Image img, float rotationAngle)
{
using (Graphics graphics = Graphics.FromImage(img))
{
graphics.TranslateTransform((float)img.Width / 2, (float)img.Height / 2);
graphics.RotateTransform(rotationAngle);
graphics.TranslateTransform(-(float)img.Width / 2, -(float)img.Height / 2);
graphics.DrawImage(img, new Point(0, 0));
}
return img;
}
【问题讨论】:
-
我已经更新了答案。
标签: c# image graphics bitmap rotation