简体   繁体   English

我想使用aspx旋转网络上的图像

[英]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.

相关问题 我想创建一个文件夹来将图像存储在C#Web应用程序中 - I would like to create a folder to store images in C# web application 我想使用正则表达式制作图案 - I would like to make a pattern using regex 如何将值从.aspx 传递到.aspx.cs? - How would I pass a value from .aspx to .aspx.cs? 在C#中使用yield就像在Ruby中一样 - using yield in C# like I would in Ruby 使用 dotPeek,我想查看 UnityEngine 命名空间的完整结构 - Using dotPeek, I would like to see the full structure of the UnityEngine namespace 使用C#,我如何在网络上的TinEye.com等Windows文件系统中搜索图像? - Using C#, how do I search for images in a Windows file system like TinEye.com does on the web? 我在div标签中有两个图像,并希望在单击它们时向这些图像添加超链接。 有任何想法吗? - i have two images in a div tag and would like to add hyperlinks to these images upon clicking them. any ideas? 使用htm将aspx网页导出为pdf - Export aspx web page to pdf using htm 在aspx网页上使用JsonObject的内容 - Using the contents of a JsonObject on aspx web page 在Aspx页面上使用AJAX Web控件时,应如何处理会话超时? - How should I handle Session timeouts when using AJAX Web controls on an Aspx page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM