How to set the rotation angle of the images in ImageView in Xamarin? [duplicate]












0
















This question is an exact duplicate of:




  • Rotate UIImage in xamarin iOS

    2 answers




I am working with Xamarin.iOS and now I want to rotate the image 90 degrees in ImageView when I click button.I found a similar issue.But it wrote in OC and Swift.How to implement it in C#?I couldn't find method such as CGAffineTransformMakeRotation.










share|improve this question













marked as duplicate by SushiHangover xamarin
Users with the  xamarin badge can single-handedly close xamarin questions as duplicates and reopen them as needed.

StackExchange.ready(function() {
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function() {
$hover.showInfoMessage('', {
messageElement: $msg.clone().show(),
transient: false,
position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
dismissable: false,
relativeToBody: true
});
},
function() {
StackExchange.helpers.removeMessages();
}
);
});
});
Nov 16 '18 at 1:41


This question was marked as an exact duplicate of an existing question.























    0
















    This question is an exact duplicate of:




    • Rotate UIImage in xamarin iOS

      2 answers




    I am working with Xamarin.iOS and now I want to rotate the image 90 degrees in ImageView when I click button.I found a similar issue.But it wrote in OC and Swift.How to implement it in C#?I couldn't find method such as CGAffineTransformMakeRotation.










    share|improve this question













    marked as duplicate by SushiHangover xamarin
    Users with the  xamarin badge can single-handedly close xamarin questions as duplicates and reopen them as needed.

    StackExchange.ready(function() {
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function() {
    $hover.showInfoMessage('', {
    messageElement: $msg.clone().show(),
    transient: false,
    position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
    dismissable: false,
    relativeToBody: true
    });
    },
    function() {
    StackExchange.helpers.removeMessages();
    }
    );
    });
    });
    Nov 16 '18 at 1:41


    This question was marked as an exact duplicate of an existing question.





















      0












      0








      0









      This question is an exact duplicate of:




      • Rotate UIImage in xamarin iOS

        2 answers




      I am working with Xamarin.iOS and now I want to rotate the image 90 degrees in ImageView when I click button.I found a similar issue.But it wrote in OC and Swift.How to implement it in C#?I couldn't find method such as CGAffineTransformMakeRotation.










      share|improve this question















      This question is an exact duplicate of:




      • Rotate UIImage in xamarin iOS

        2 answers




      I am working with Xamarin.iOS and now I want to rotate the image 90 degrees in ImageView when I click button.I found a similar issue.But it wrote in OC and Swift.How to implement it in C#?I couldn't find method such as CGAffineTransformMakeRotation.





      This question is an exact duplicate of:




      • Rotate UIImage in xamarin iOS

        2 answers








      xamarin xamarin.ios






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 16 '18 at 0:36









      MonkeySteveMonkeySteve

      647




      647




      marked as duplicate by SushiHangover xamarin
      Users with the  xamarin badge can single-handedly close xamarin questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 16 '18 at 1:41


      This question was marked as an exact duplicate of an existing question.









      marked as duplicate by SushiHangover xamarin
      Users with the  xamarin badge can single-handedly close xamarin questions as duplicates and reopen them as needed.

      StackExchange.ready(function() {
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() {
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function() {
      $hover.showInfoMessage('', {
      messageElement: $msg.clone().show(),
      transient: false,
      position: { my: 'bottom left', at: 'top center', offsetTop: -7 },
      dismissable: false,
      relativeToBody: true
      });
      },
      function() {
      StackExchange.helpers.removeMessages();
      }
      );
      });
      });
      Nov 16 '18 at 1:41


      This question was marked as an exact duplicate of an existing question.


























          2 Answers
          2






          active

          oldest

          votes


















          2














          Try to refer the following code



          public UIImage RotateImage(UIImage image, float degree)
          {
          float Radians = degree * (float)Math.PI / 180;

          UIView view = new UIView(frame: new CGRect(0, 0, image.Size.Width, image.Size.Height));
          CGAffineTransform t = CGAffineTransform.MakeRotation(Radians);
          view.Transform = t;
          CGSize size = view.Frame.Size;

          UIGraphics.BeginImageContext(size);
          CGContext context = UIGraphics.GetCurrentContext();

          context.TranslateCTM(size.Width/2, size.Height/2);
          context.RotateCTM(Radians);
          context.ScaleCTM(1, -1);

          context.DrawImage(new CGRect(-image.Size.Width/2, -image.Size.Height/2, image.Size.Width, image.Size.Height), image.CGImage);

          UIImage imageCopy = UIGraphics.GetImageFromCurrentImageContext();
          UIGraphics.EndImageContext();

          return imageCopy;
          }


          Then you can reset the image of UIImageView.
          Here is a similar issue you can refer .






          share|improve this answer


























          • It works ! Thank you lucas. You and your colleagues saved me from time to time.

            – MonkeySteve
            Nov 16 '18 at 1:33











          • You are welcome .Happy coding:)

            – Lucas Zhang - MSFT
            Nov 16 '18 at 1:34











          • Not very happy .I've been working 30 hours overtime without sleep.

            – MonkeySteve
            Nov 16 '18 at 1:36



















          1














          in Xamarin it's CGAffineTransform.MakeRotation



          using CoreGraphics;

          // 1.5708 is 90 degrees in Radians
          myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);





          share|improve this answer
























          • Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

            – MonkeySteve
            Nov 16 '18 at 0:51


















          2 Answers
          2






          active

          oldest

          votes








          2 Answers
          2






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          2














          Try to refer the following code



          public UIImage RotateImage(UIImage image, float degree)
          {
          float Radians = degree * (float)Math.PI / 180;

          UIView view = new UIView(frame: new CGRect(0, 0, image.Size.Width, image.Size.Height));
          CGAffineTransform t = CGAffineTransform.MakeRotation(Radians);
          view.Transform = t;
          CGSize size = view.Frame.Size;

          UIGraphics.BeginImageContext(size);
          CGContext context = UIGraphics.GetCurrentContext();

          context.TranslateCTM(size.Width/2, size.Height/2);
          context.RotateCTM(Radians);
          context.ScaleCTM(1, -1);

          context.DrawImage(new CGRect(-image.Size.Width/2, -image.Size.Height/2, image.Size.Width, image.Size.Height), image.CGImage);

          UIImage imageCopy = UIGraphics.GetImageFromCurrentImageContext();
          UIGraphics.EndImageContext();

          return imageCopy;
          }


          Then you can reset the image of UIImageView.
          Here is a similar issue you can refer .






          share|improve this answer


























          • It works ! Thank you lucas. You and your colleagues saved me from time to time.

            – MonkeySteve
            Nov 16 '18 at 1:33











          • You are welcome .Happy coding:)

            – Lucas Zhang - MSFT
            Nov 16 '18 at 1:34











          • Not very happy .I've been working 30 hours overtime without sleep.

            – MonkeySteve
            Nov 16 '18 at 1:36
















          2














          Try to refer the following code



          public UIImage RotateImage(UIImage image, float degree)
          {
          float Radians = degree * (float)Math.PI / 180;

          UIView view = new UIView(frame: new CGRect(0, 0, image.Size.Width, image.Size.Height));
          CGAffineTransform t = CGAffineTransform.MakeRotation(Radians);
          view.Transform = t;
          CGSize size = view.Frame.Size;

          UIGraphics.BeginImageContext(size);
          CGContext context = UIGraphics.GetCurrentContext();

          context.TranslateCTM(size.Width/2, size.Height/2);
          context.RotateCTM(Radians);
          context.ScaleCTM(1, -1);

          context.DrawImage(new CGRect(-image.Size.Width/2, -image.Size.Height/2, image.Size.Width, image.Size.Height), image.CGImage);

          UIImage imageCopy = UIGraphics.GetImageFromCurrentImageContext();
          UIGraphics.EndImageContext();

          return imageCopy;
          }


          Then you can reset the image of UIImageView.
          Here is a similar issue you can refer .






          share|improve this answer


























          • It works ! Thank you lucas. You and your colleagues saved me from time to time.

            – MonkeySteve
            Nov 16 '18 at 1:33











          • You are welcome .Happy coding:)

            – Lucas Zhang - MSFT
            Nov 16 '18 at 1:34











          • Not very happy .I've been working 30 hours overtime without sleep.

            – MonkeySteve
            Nov 16 '18 at 1:36














          2












          2








          2







          Try to refer the following code



          public UIImage RotateImage(UIImage image, float degree)
          {
          float Radians = degree * (float)Math.PI / 180;

          UIView view = new UIView(frame: new CGRect(0, 0, image.Size.Width, image.Size.Height));
          CGAffineTransform t = CGAffineTransform.MakeRotation(Radians);
          view.Transform = t;
          CGSize size = view.Frame.Size;

          UIGraphics.BeginImageContext(size);
          CGContext context = UIGraphics.GetCurrentContext();

          context.TranslateCTM(size.Width/2, size.Height/2);
          context.RotateCTM(Radians);
          context.ScaleCTM(1, -1);

          context.DrawImage(new CGRect(-image.Size.Width/2, -image.Size.Height/2, image.Size.Width, image.Size.Height), image.CGImage);

          UIImage imageCopy = UIGraphics.GetImageFromCurrentImageContext();
          UIGraphics.EndImageContext();

          return imageCopy;
          }


          Then you can reset the image of UIImageView.
          Here is a similar issue you can refer .






          share|improve this answer















          Try to refer the following code



          public UIImage RotateImage(UIImage image, float degree)
          {
          float Radians = degree * (float)Math.PI / 180;

          UIView view = new UIView(frame: new CGRect(0, 0, image.Size.Width, image.Size.Height));
          CGAffineTransform t = CGAffineTransform.MakeRotation(Radians);
          view.Transform = t;
          CGSize size = view.Frame.Size;

          UIGraphics.BeginImageContext(size);
          CGContext context = UIGraphics.GetCurrentContext();

          context.TranslateCTM(size.Width/2, size.Height/2);
          context.RotateCTM(Radians);
          context.ScaleCTM(1, -1);

          context.DrawImage(new CGRect(-image.Size.Width/2, -image.Size.Height/2, image.Size.Width, image.Size.Height), image.CGImage);

          UIImage imageCopy = UIGraphics.GetImageFromCurrentImageContext();
          UIGraphics.EndImageContext();

          return imageCopy;
          }


          Then you can reset the image of UIImageView.
          Here is a similar issue you can refer .







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 16 '18 at 1:55

























          answered Nov 16 '18 at 0:51









          Lucas Zhang - MSFTLucas Zhang - MSFT

          2,6622210




          2,6622210













          • It works ! Thank you lucas. You and your colleagues saved me from time to time.

            – MonkeySteve
            Nov 16 '18 at 1:33











          • You are welcome .Happy coding:)

            – Lucas Zhang - MSFT
            Nov 16 '18 at 1:34











          • Not very happy .I've been working 30 hours overtime without sleep.

            – MonkeySteve
            Nov 16 '18 at 1:36



















          • It works ! Thank you lucas. You and your colleagues saved me from time to time.

            – MonkeySteve
            Nov 16 '18 at 1:33











          • You are welcome .Happy coding:)

            – Lucas Zhang - MSFT
            Nov 16 '18 at 1:34











          • Not very happy .I've been working 30 hours overtime without sleep.

            – MonkeySteve
            Nov 16 '18 at 1:36

















          It works ! Thank you lucas. You and your colleagues saved me from time to time.

          – MonkeySteve
          Nov 16 '18 at 1:33





          It works ! Thank you lucas. You and your colleagues saved me from time to time.

          – MonkeySteve
          Nov 16 '18 at 1:33













          You are welcome .Happy coding:)

          – Lucas Zhang - MSFT
          Nov 16 '18 at 1:34





          You are welcome .Happy coding:)

          – Lucas Zhang - MSFT
          Nov 16 '18 at 1:34













          Not very happy .I've been working 30 hours overtime without sleep.

          – MonkeySteve
          Nov 16 '18 at 1:36





          Not very happy .I've been working 30 hours overtime without sleep.

          – MonkeySteve
          Nov 16 '18 at 1:36













          1














          in Xamarin it's CGAffineTransform.MakeRotation



          using CoreGraphics;

          // 1.5708 is 90 degrees in Radians
          myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);





          share|improve this answer
























          • Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

            – MonkeySteve
            Nov 16 '18 at 0:51
















          1














          in Xamarin it's CGAffineTransform.MakeRotation



          using CoreGraphics;

          // 1.5708 is 90 degrees in Radians
          myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);





          share|improve this answer
























          • Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

            – MonkeySteve
            Nov 16 '18 at 0:51














          1












          1








          1







          in Xamarin it's CGAffineTransform.MakeRotation



          using CoreGraphics;

          // 1.5708 is 90 degrees in Radians
          myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);





          share|improve this answer













          in Xamarin it's CGAffineTransform.MakeRotation



          using CoreGraphics;

          // 1.5708 is 90 degrees in Radians
          myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);






          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 16 '18 at 0:48









          JasonJason

          52.4k1291119




          52.4k1291119













          • Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

            – MonkeySteve
            Nov 16 '18 at 0:51



















          • Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

            – MonkeySteve
            Nov 16 '18 at 0:51

















          Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

          – MonkeySteve
          Nov 16 '18 at 0:51





          Thanks! Jason. But I just want to rotation the image and reset the image of imageview.

          – MonkeySteve
          Nov 16 '18 at 0:51



          Popular posts from this blog

          Bressuire

          Vorschmack

          Quarantine