Danpe
Danpe

Reputation: 19047

C# Image Rotation using AForge.NET libraries?

Why my image wont rotate?

    Image map = Properties.Resources.Map;

    //Creates a new Bitmap as the size of the window
    Bitmap bmp = new Bitmap(map.Width, map.Height);
    //Creates a new graphics to handle the image that is coming from the stream
    Graphics g = Graphics.FromImage((Image)bmp);
    g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBilinear;

    MapY += (js.State.Y - 500)/100;
    MapRotation += (js.State.X - 500)/100;

    RotateBilinear filter = new RotateBilinear(30, true);
    g.DrawImage(map, 0, MapY, map.Width, map.Height);

    Bitmap newbmp = bmp.Clone(new Rectangle(0, 0, bmp.Width, bmp.Height), System.Drawing.Imaging.PixelFormat.Format24bppRgb);

    filter.Apply(newbmp);
    picBoxMap.Image = (Image)newbmp;

Upvotes: 0

Views: 3433

Answers (1)

Bob2Chiv
Bob2Chiv

Reputation: 1968

filter.Apply(newbmp) 

returns a bitmap of the rotated image.

My guess is since you don't assign a new bitmap, it is lost.

Try:

Bitmap rotatedBmp = filter.Apply(newbmp)

Then use the rotatedBmp for whatever you wanted.

Upvotes: 3

Related Questions