[英]I would like to rotate images on the web using aspx
I am writing an application ( .NET 4.0 using web forms). 我正在编写一个应用程序(使用Web窗体的.NET 4.0)。 What I like to do is to give the ability for users to see images they have stored in a directory and be able to perform changes to their pictures ( zoom, rotate, crop, etc).
我想做的是使用户能够查看他们存储在目录中的图像,并能够对其图片进行更改(缩放,旋转,裁剪等)。 I can do the zoom, rotate and crop in winforms, but I can't figure out how to display it in aspx without saving it.
我可以在winforms中进行缩放,旋转和裁剪,但是我不知道如何在不保存的情况下以aspx格式显示它。
so imagine image A displayed in an image control. 想象一下图像A显示在图像控件中。 User clicks on it to zoom.
用户单击它进行缩放。 I pass it to a method.
我将其传递给一个方法。 it rotates.
它旋转。 But how do I redisplay it rotated?
但是,如何重新显示旋转的图像? Do I have to save the image and then display it?
我必须先保存图像然后再显示吗? Maybe I am going about this all wrong.
也许我要解决所有这些错误。 Does someone have a sample code to accomplish this?
有人有示例代码可以完成此操作吗? Sample code to display an image on an aspx and rotate and show the rotated image.
用于在aspx上显示图像并旋转并显示旋转的图像的示例代码。
Thanks 谢谢
Try this: 尝试这个:
protected void Button1_Click(object sender, EventArgs e)
{
// get the full path of image url
string path = Server.MapPath(Image1.ImageUrl) ;
// creating image from the image url
System.Drawing.Image i = System.Drawing.Image.FromFile(path);
// rotate Image 90' Degree
i.RotateFlip(RotateFlipType.Rotate90FlipXY);
// save it to its actual path
i.Save(path);
// release Image File
i.Dispose();
// Set Image Control Attribute property to new image(but its old path)
Image1.Attributes.Add("ImageUrl", path);
}
Maybe this link will point you in the right direction. 也许此链接将为您指明正确的方向。 ASP.NET friendly image editor
ASP.NET友好的图像编辑器
Win and web forms are 2 totally different beasts, and short of saving it to the sever on each and every change, you'd really want to have the client handle most of the work until they hit save. Win和Web表单是2种完全不同的野兽,并且在每次更改时都没有将其保存到服务器上,因此,您确实希望让客户端处理大部分工作,直到他们点击保存。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.