src/NetStandard/Drawing/Drawing/src/Extensions/Image.cs
/// <summary>
/// Creates a rotated image from the image that got passed.
/// </summary>
/// <param name="image">The image to be rotated.</param>
/// <param name="offset">The position to rotate from.</param>
/// <param name="angle">The amount to rotate the image, clockwise, in degrees.</param>
/// <returns>A new <see cref="Bitmap"/> of the same size rotated.</returns>
/// <exception cref="ArgumentNullException">Thrown if image is null.</exception>
Creates a rotated image from the image that got passed.
Creates a rotated image from the image that got passed .
public static Bitmap RotateImage(this Image image, PointF offset, float angle)
        {
            if (image == null) {
                throw new ArgumentNullException("image");
            }
            var rotatedBmp = new Bitmap(image.Width, image.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            rotatedBmp.SetResolution(image.HorizontalResolution, image.VerticalResolution);
            var 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));
            return rotatedBmp;
        }
public static Bitmap RotateImage ( this Image image , PointF offset , float angle ) { if ( image == null ) { throw new ArgumentNullException ( " " ) ; } var rotatedBmp = new Bitmap ( image . Width , image . Height , System . Drawing . Imaging . PixelFormat . Format32bppArgb ) ; rotatedBmp . SetResolution ( image . HorizontalResolution , image . VerticalResolution ) ; var 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 ) ) ; return rotatedBmp ; }
Creates a rotated image from the image that got passed.
Creates a rotated image from the image that got passed .
//create a new empty bitmap to hold rotated image //make a graphics object from the empty bitmap //Put the rotation point in the center of the image //rotate the image //move the image back //draw passed in image onto graphics object
A new  of the same size rotated.
A new of the same size rotated .
Thrown if image is null.
Thrown if image is null .
Image
this
offset
PointF
The position to rotate from.
The position to rotate from .
angle
float
The amount to rotate the image, clockwise, in degrees.
The amount to rotate the image clockwise in degrees .
image
The image to be rotated.
The image to be rotated .