Tuesday, October 18, 2011

Flip Horizontally in asp.net with c#

.aspx
--------
   <asp:Button ID="btflip" runat="server" Text="flip" onclick="btflip_Click" />

 .aspx.cs
---------

 protected void btflip_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 180' Degree
        i.RotateFlip(RotateFlipType.Rotate180FlipY);

        // 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);

    }



No comments:

Post a Comment