using System.Drawing.Drawing2D;
namespace RotatePictureBox
public sealed class Utilities
public static Bitmap RotateImage(Image image, float angle)
return RotateImage(image, new PointF((float)image.Width / 2, (float)image.Height / 2), angle);
public static Bitmap RotateImage(Image image, PointF offset, float angle)
throw new ArgumentNullException("image");
Bitmap rotatedBmp = new Bitmap(image.Width, image.Height);
rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
Graphics g = Graphics.FromImage(rotatedBmp);
g.TranslateTransform(offset.X, offset.Y);
g.RotateTransform(angle);
g.TranslateTransform(-offset.X, -offset.Y);
g.DrawImage(image, new PointF(0, 0));