方法1:
private void RotateFormCenter(PictureBox pb, float angle)
{
Image img = pb.Image;
int newWidth = Math.Max(img.Height, img.Width);
Bitmap bmp = new Bitmap(newWidth, newWidth);
Graphics g = Graphics.FromImage(bmp);
Matrix x = new Matrix();
PointF point = new PointF(img.Width / 2f, img.Height / 2f);
x.RotateAt(angle, point);
g.Transform = x;
g.DrawImage(img, 0, 0);
g.Dispose();
img = bmp;
pb.Image = img;
}
该方法通过将图片转化为用于几何变换的3x3矩阵 对图片进行旋转。
缺点:有时图片会越转越模糊。
方法2:
private void RotateF