旋转影像 [英] Rotate Image

查看:61
本文介绍了旋转影像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下代码旋转图像:

I am rotating an image using the following code:

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();
}



旋转确实发生,但是每次单击按钮都会覆盖原始图像.

场景:
1.我有一个显示图像的网格.
2.在网格视图中单击的图像显示在图像控件中.
3.现在,我在此图像控件上应用旋转功能.
我发现上面提到的方法会覆盖图像,并且在gridview中显示的图像也会旋转.我不想这样.
旋转仅应在其中显示的图像的图像"控件中发生.



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.

推荐答案

好了,嗯.您的代码将其保存,您期望得到什么?您可以保存为其他文件名,也可以编写HTTP处理程序以返回旋转的图像字节,而无需实际保存图像.
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.


这篇关于旋转影像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆