How to set the rotation angle of the images in ImageView in Xamarin? [duplicate]
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
.
xamarin xamarin.ios
marked as duplicate by SushiHangover
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.
add a comment |
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
.
xamarin xamarin.ios
marked as duplicate by SushiHangover
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.
add a comment |
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
.
xamarin xamarin.ios
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
xamarin xamarin.ios
asked Nov 16 '18 at 0:36
MonkeySteveMonkeySteve
647
647
marked as duplicate by SushiHangover
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
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.
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
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 .
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
add a comment |
in Xamarin it's CGAffineTransform.MakeRotation
using CoreGraphics;
// 1.5708 is 90 degrees in Radians
myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
Thanks! Jason. But I just want to rotation the image and reset the image of imageview.
– MonkeySteve
Nov 16 '18 at 0:51
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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 .
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
add a comment |
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 .
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
add a comment |
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 .
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 .
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
add a comment |
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
add a comment |
in Xamarin it's CGAffineTransform.MakeRotation
using CoreGraphics;
// 1.5708 is 90 degrees in Radians
myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
Thanks! Jason. But I just want to rotation the image and reset the image of imageview.
– MonkeySteve
Nov 16 '18 at 0:51
add a comment |
in Xamarin it's CGAffineTransform.MakeRotation
using CoreGraphics;
// 1.5708 is 90 degrees in Radians
myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
Thanks! Jason. But I just want to rotation the image and reset the image of imageview.
– MonkeySteve
Nov 16 '18 at 0:51
add a comment |
in Xamarin it's CGAffineTransform.MakeRotation
using CoreGraphics;
// 1.5708 is 90 degrees in Radians
myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
in Xamarin it's CGAffineTransform.MakeRotation
using CoreGraphics;
// 1.5708 is 90 degrees in Radians
myImageView.Transform = CGAffineTransform.MakeRotation(1.5708f);
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
add a comment |
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
add a comment |