public static Image RotateImage(Image img, float rotationAngle){//create an empty Bitmap imageBitmap bmp = new Bitmap(img.Width, img.Height);//turn the Bitmap into a Graphics objectGraphics gfx = Graphics.FromImage(bmp);//now we set the rotation point to the center of our imagegfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);//now rotate the imagegfx.RotateTransform(rotationAngle);gfx.TranslateTransform(-(float)bmp.Width / 2, -(float)bmp.Height / 2);//set the InterpolationMode to HighQualityBicubic so to ensure a high//quality image once it is transformed to the specified sizegfx.InterpolationMode = InterpolationMode.HighQualityBicubic;//now draw our new image onto the graphics objectgfx.DrawImage(img, new Point(0, 0));//dispose of our Graphics objectgfx.Dispose();//return the imagereturn bmp;}
Loading

