This has been bothering me for ages, I just want a simple method that rotates an image X degrees. (this is for a turret defense game in which the turrets need to shoot a certain direction)
I want something like this:
public Image getRotatedImage(Image img, float angle)
{
//Code here to rotate the image
return img
}
All of this in c# wpf ofcourse and dynamically.. Hope you guys can help me out here :D
Don't use code to change your image. Let WPF rotate it for you using a RotateTransform.
<Image ...>
<Image.RenderTransform>
<RotateTransform Angle="45" />
</Image.RenderTransform>
</Image >
Or apply a RotateTransform to your image in code:
RotateTransform rotateTransform = new RotateTransform(45);
img.RenderTransform = rotateTransform;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With