Friday, January 10, 2014

Rotate Image In Asp.Net .

Here I am going to explain ,How can you rotate image using asp.net.
You can Rotate image 90 Degree and 180 Degree.
Previously I Explain Save data in SqlServer database in any language (hindi, english,Odia, marathi, etc) using Asp.Net (C#).

Very Easy way to Rotate a image according to your
Requirement.

Download Code Here

Demo :


Step 1: Copy and Paste The below Code in .aspx page.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Rotate Image</title>
    
</head>
<body>
    <form id="form1" runat="server">
    <div>
  
           Rotate Image <asp:Image ID="Image1" runat="server" BorderColor="silver" 
             BorderWidth="2" Height="198px" ImageUrl="~/dot.png" 
            Width="241px" />
<span class="style1">Here You can Rotate Image according 
to your Requairment.Here I Rotate 
Image 90 degree (180 degree).
</span>
                           <asp:Button ID="Rotate" runat="server" Font-Bold="true" 
             Height="40px" OnClick="Rotate_Click
            Text="Rotate Image"  />
    </div>
    </form>
</body>
</html>

Step 2: Now Namespace 

 using System.Drawing.Drawing2D;
using System.Drawing;
using System.Drawing.Imaging;

Now Copy the Below Code and Paste in .aspx.cs page

 protected void Rotate_Click(object sender, EventArgs e)
    {
// dot.png Replace it to your image name
        String path = Server.MapPath("dot.png");
        System.Drawing.Image img = System.Drawing.Image.FromFile(path);
        img.RotateFlip(RotateFlipType.Rotate90FlipNone);
//  img.RotateFlip(RotateFlipType.Rotate180FlipNone);
        img.Save(path); 
    }


If This Code Help You, Please Share.

1 comment: