Hi,
Your problem is that each time your rotate your image you are using you image store it's rotation as it's image rotation is set to 90 degrees it will not rotate any more it is rather simple to work around. Simply declare an int to store your rotation angle set it to 0 and add 90 degrees each time you call your function.
int Rotate_angle = 0;
private void Button_Click(object sender, RoutedEventArgs e)
{
TransformedBitmap TempImage = new TransformedBitmap();
TempImage.BeginInit();
TempImage.Source = MyImageSource;
RotateTransform transform = new RotateTransform(Rotate_angle+=90);
TempImage.Transform = transform;
TempImage.EndInit();
image1.Source = TempImage ;
}
A much simpler method if you have your Image displayed in an Image control named "img" like this
<grid>
<stackpanel>
<Image Name="img" Source="01.jpg"/>
<Button Click="Button_Click" Content="CLICK"/>
</stackpanel>
</grid>
is to put this as your code behind;
int Rotate_angle = 0;
private void Button_Click(object sender, RoutedEventArgs e)
{
img.RenderTransformOrigin = new Point(0.5, 0.5);
img.RenderTransform = new RotateTransform(Rotate_angle+=45);
}
This method is cleaner and allows you to rotate by different angles.
Hope this helps you
Cheers
Chris