C# rotate bitmap 90 degrees

前端 未结 3 830
误落风尘
误落风尘 2020-12-03 06:10

I\'m trying to rotate a bitmap 90 degrees using the following function. The problem with it is that it cuts off part of the image when the height and width are not equal.

3条回答
  •  天涯浪人
    2020-12-03 06:59

    What about this:

    private void RotateAndSaveImage(String input, String output)
    {
        //create an object that we can use to examine an image file
        using (Image img = Image.FromFile(input))
        {
            //rotate the picture by 90 degrees and re-save the picture as a Jpeg
            img.RotateFlip(RotateFlipType.Rotate90FlipNone);
            img.Save(output, System.Drawing.Imaging.ImageFormat.Jpeg);
        }
    }
    

提交回复
热议问题