c# - 图像旋转翻转 ASP.NET C#

标签 c# asp.net image rotation flip

这是我尝试在我的 Web 应用程序 ASP.NET 中旋转图像的第五天,互联网上的所有解决方案都不适合我。

这是我在 .aspx.cs 中的代码

protected void BtnRotateImage_Click(object sender, EventArgs e)
    {
        string vImageName = LblFarmId.Text;

        string vPath = "~/attachments/survey/" + vImageName + ".jpg";

        Image1.ImageUrl = vPath;

        //get the path to the image
        string path = Server.MapPath(vPath);

        //create an image object from the image in that path
        System.Drawing.Image img = System.Drawing.Image.FromFile(path);

        //rotate the image
        img.RotateFlip(RotateFlipType.Rotate90FlipXY);

        //save the image out to the file
        img.Save(path);

        //release image file
        img.Dispose();

    }

在 .aspx 页面中

<asp:Image ID="Image1" runat="server" ImageUrl=""  width="600" height="800"/>

我点击按钮,没有任何反应,图像没有旋转。

我的代码有什么问题吗?

最佳答案

当您点击按钮时,您只是在保存图像。图片保存后,您需要重新加载页面,并将图片标签设置为新路径。

关于c# - 图像旋转翻转 ASP.NET C#,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30135319/

相关文章:

c# - 正则表达式 (RegEx) - 一个字符串可变长度

仅使用 Response.Write 的 ASP.NET 页面

android - 使用VB.NET向android模拟器发送通知得到错误401

c# - 将图像中的每个像素设置为颜色列表中最接近的匹配项

使用 Monotouch (Xamarin) 的 iOS 图像,旋转图像

c# - 使用静态构造函数初始化类?

c# - 尝试在 C# 控制台应用程序中运行多个异步任务

java - 使用谷歌应用程序引擎图像Java API减小图像大小失败

c# - 从 MySql 数据库收集数据后,我的 ASP.NET 应用程序不显示填充的 GridView

ASP.NET - 脚本和 css 压缩