On Sat, Feb 13, 2010 at 1:27 PM, [email protected] <[email protected]>wrote:

> Thanks for reply
>
> code is as per bellow
>
> using System;
> using System.Data;
> using System.Configuration;
> using System.Collections;
> using System.Web;
> using System.Web.Security;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.WebControls.WebParts;
> using System.Web.UI.HtmlControls;
> using System.IO;
> using System.Drawing;
> using System.Drawing.Imaging;
> using System.Drawing.Text;
> using System.Drawing.Drawing2D;
>
> public partial class rotateimage : System.Web.UI.Page
> {
>    protected void Page_Load(object sender, EventArgs e)
>    {
>        String imagepath = pathstr() + "Images\\sellimage.jpg";
>        Bitmap bmp_conv_dpi = new Bitmap(imagepath);
>        System.Drawing.Image i =
> Rotateimage((System.Drawing.Image)bmp_conv_dpi,double.Parse(
> queryStringValue(Request,"angle",
> 0)));
>        MemoryStream ms = new MemoryStream();
>        i.Save(ms, ImageFormat.Png);
>        Response.ContentType = "image/PNG";
>        ms.WriteTo(Response.OutputStream);
>        Response.End();
>    }
>    public string pathstr()
>    {
>        return System.AppDomain.CurrentDomain.BaseDirectory;
>    }
>    public static System.Drawing.Image
> Rotateimage(System.Drawing.Image image, double angle)
>    {
>
>        if (image == null)
>        {
>            throw new ArgumentNullException("image");
>        }
>        float oldWidth = (float)image.Width;
>        float oldHeight = (float)image.Height;
>
>        // Ensure angle is [0, 360)
>        angle = angle % 360f;
>        if (angle < 0.0)
>        {
>            angle += 360f;
>        }
>
>        PointF[] corners = new PointF[4];
>        // corners, clockwise from upper left
>        // corners[0] is origin
>        corners[1].X = oldWidth;
>        corners[2].X = oldWidth;
>        corners[2].Y = oldHeight;
>        corners[3].Y = oldHeight;
>
>        // rotate about origin
>        Matrix m = new Matrix();
>        m.Rotate((float)angle);
>        m.TransformPoints(corners);
>
>        // compute bounds of transformed corners from largest and
> smallest x and y values
>        double maxX = Double.MinValue;
>        double maxY = Double.MinValue;
>        double minX = Double.MaxValue;
>        double minY = Double.MaxValue;
>        foreach (PointF p in corners)
>        {
>            maxX = Math.Max(maxX, p.X);
>            minX = Math.Min(minX, p.X);
>            maxY = Math.Max(maxY, p.Y);
>            minY = Math.Min(minY, p.Y);
>        }
>        double newWidth = Math.Ceiling(maxX - minX);
>        double newHeight = Math.Ceiling(maxY - minY);
>
>        Bitmap rotatedBmp = new Bitmap((int)newWidth, (int)newHeight);
>        using (Graphics g = Graphics.FromImage(rotatedBmp))
>        {
>            // center of new image
>            PointF center = new PointF((float)(newWidth / 2), (float)
> (newHeight / 2));
>            g.SmoothingMode =
> System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
>            // position to draw old image to center it in new one
>            PointF position = new PointF(center.X - oldWidth / 2,
> center.Y - oldHeight / 2);
>
>            // rotate about center and draw
>            m.Reset();
>            m.RotateAt((float)angle, center);
>            g.Transform = m;
>            g.DrawImage(image, position);
>            m.Reset();
>
>
>            g.InterpolationMode =
> System.Drawing.Drawing2D.InterpolationMode.Bicubic;
>        }
>
>
>
>
>        return rotatedBmp;
>    }
>    public static string queryStringValue(HttpRequest wr, string key,
> object defaultValue)
>    {
>        try
>        {
>            return wr.QueryString[key].ToString();
>        }
>        catch (Exception)
>        { }
>        return defaultValue.ToString();
>    }
> }
>
>
> On Feb 11, 4:27 pm, Jamie Fraser <[email protected]> wrote:
> > The effect you are seeing is image distortion due to the
> square/rectangular
> > pixels on a display screen being unable to display a straight edge when
> the
> > edge is non-orthogonal with the actual display grid.
> >
> > You need to implement anti-aliasing of some sort to reduce this effect.
> >
> > If you need any help specific to implementing anti-aliasing in your
> > solution, post the code you have so far.
> >
> > On Thu, Feb 11, 2010 at 6:50 AM, [email protected] <
> [email protected]>wrote:
> >
> > > not it is not spam , it's urgent to solve
> >
> > > On Feb 10, 5:49 pm, Processor Devil <[email protected]> wrote:
> > > > spam?
> >
> > > > 2010/2/10 [email protected] <[email protected]>
> >
> > > > > please check url below and find how the image distorts at edges on
> > > > > giving rotation angles like 5,10,50 etc. however the edges are
> smooth
> > > > > and crisp on 45 degree
> >
> > > > >http://cybersurf.in/rotationtesting.aspx
> >
> > > > > please provide solution ASAP.
>

Reply via email to