semmyenator:
public static Image RotateImage(Image img, float rotationAngle)
{
Bitmap bmp = new Bitmap(img.Width, img.Height);
//Create same-size images.
Graphics gfx = Graphics.FromImage(bmp);
gfx.RotateTransform(rotationAngle);
//Rotate the image according to the incoming angle.
gfx.TranslateTransform((float)bmp.Width / 2 - img.Width / 2, (float)bmp.Height / 2 - img.Height / 2);
//Create a rotation point, this line is the center point of the image.
gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
//Set InterpolationMode to HighQualityBicubic to ensure that it does not deform after rotation.
gfx.DrawImage(img, new Point(0, 0));
//Redraw the picture.
gfx.Dispose();
return bmp;
}
10-06 21:41