Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am rotating an image using the following code:
C#
protected void Button2_Click1(object sender, EventArgs e)
{
string abc = Server.MapPath(Image2.ImageUrl.Replace("/", "\\"));
System.Drawing.Image img = System.Drawing.Image.FromFile(abc);
img.RotateFlip(System.Drawing.RotateFlipType.Rotate90FlipNone);

//re-save the picture as a Jpeg
img.Save(abc, System.Drawing.Imaging.ImageFormat.Jpeg);

//tidy up after we've finished
img.Dispose();
}


The rotation does happen but it is overwriting the original image on every click of button.

Scenario:
1. I have a grid showing images.
2. The image that is clicked in gridview is displayed in Image control.
3. Now, I apply rotate function on this image control.
I found the method mentioned above is overwriting the image and the image displayed in gridview also rotates. I do not want this.
Rotation should happen only in Image control for the image that is displayed in it.
Posted
Updated 19-Aug-10 20:33pm
v2

1 solution

Well, duh. Your code saves it, what did you expect ? You can save to a different file name, or you can write a HTTP handler that returns the rotated image bytes without actually saving the image.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900