这是我尝试在Web应用程序ASP.NET中旋转图像的第五天,Internet上的所有解决方案都无法使用。
这是我在.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"/>
我单击按钮,没有任何反应,图像没有旋转。
我的代码有什么错误吗?
单击按钮时,仅保存图像。保存图像后,您需要重新加载页面,并将图像标签设置为新路径。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句