【问题标题】:Image.RotateFlip() API for anti-clock wise rotationImage.RotateFlip() API 用于逆时针旋转
【发布时间】:2015-01-21 09:06:39
【问题描述】:

如何使用

逆时针旋转图像
Image.RotateFlip() 

有可能吗??

【问题讨论】:

    标签: c# .net winforms image-rotation


    【解决方案1】:

    顺时针旋转 270 度与逆时针旋转 90 度相同。

    【讨论】:

      【解决方案2】:

      这是一种可用于在 C# 中旋转图像的方法:

      /// method to rotate an image either clockwise or counter-clockwise
      /// </summary>
      /// <param name="img">the image to be rotated</param>
      /// <param name="rotationAngle">the angle (in degrees).
      /// NOTE: 
      /// Positive values will rotate clockwise
      /// negative values will rotate counter-clockwise
      /// </param>
      /// <returns></returns>
      public static Image RotateImage(Image img, float rotationAngle)
      {
          //create an empty Bitmap image
          Bitmap bmp = new Bitmap(img.Width, img.Height);
      
          //turn the Bitmap into a Graphics object
          Graphics gfx = Graphics.FromImage(bmp);
      
          //now we set the rotation point to the center of our image
          gfx.TranslateTransform((float)bmp.Width / 2, (float)bmp.Height / 2);
      
          //now rotate the image
          gfx.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 size
          gfx.InterpolationMode = InterpolationMode.HighQualityBicubic;
      
          //now draw our new image onto the graphics object
          gfx.DrawImage(img, new Point(0, 0));
      
          //dispose of our Graphics object
          gfx.Dispose();
      
          //return the image
          return bmp;
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-11-27
        • 1970-01-01
        • 2011-07-26
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多