简体   繁体   English

使用AForge.NET库的C#图像旋转?

[英]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;
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. 然后,根据需要使用rotatedBmp。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM