C#旋转图像后失真,边缘锯齿严重

使用使用System.Drawing.Drawing2D.Matrix.RotateAt(),旋转图像后边缘锯齿严重,图像失真

用代码块功能插入代码,请勿粘贴截图
if (_IsLeftDown)
            {
                Point[] points = new Point[] { e.Location };
                Matrix matrix_Invert = _matrix.Clone();
                matrix_Invert.Invert();
                matrix_Invert.TransformPoints(points);

                switch(_ClickArea)
                {
                    case CLICK_AREA.AREA_IMG:
                        {
                            _matrix.Translate((points[0].X - _LastPt.X), (points[0].Y - _LastPt.Y));
                           // _LastPt = points[0];
                        }
                        break;
                    case CLICK_AREA.AREA_IMG_ROUTE:
                        {
                            double corrb = Math.Atan2(_LastPt.Y - _rcImg.Height / 2, _LastPt.X - _rcImg.Width / 2);
                            double corre = Math.Atan2(points[0].Y - _rcImg.Height / 2, points[0].X - _rcImg.Width / 2);
                            _matrix.RotateAt((float)((corre -corrb) *180.0f/Math.PI), new Point(_rcImg.Width / 2, _rcImg.Height / 2));
                            DRoute += (Double)((corre - corrb) * 180.0f / Math.PI);
                            Console.WriteLine(DRoute);
                        }
                        break;
                    case CLICK_AREA.AREA_IMG_SCALING:
                        {
                           
                        }
                        break;
                    default:
                        break;

                }
                Refresh();
            }
        }

运行结果及报错内容

img

img

Graphics bitImg_g = Graphics.FromImage(bitImg);
bitImg_g.SmoothingMode = SmoothingMode.HighQuality;
bitImg_g.InterpolationMode = InterpolationMode.HighQualityBicubic;
bitImg_g.CompositingQuality = CompositingQuality.HighQuality;

C# 大多数情况不自己做矩阵仿射变换,旋转图片是Gdi+本身的功能,抗锯齿也是Gdi+本身的功能
所以正常情况下,你直接开着抗锯齿用GDi+的旋转就成

至于你现在的代码,直接用矩阵仿射变换的,需要另外在对边缘做一次抗锯齿运算(插值,或者边缘模糊)----原因高DPI条件下像素点多,所以边缘需要更高精度的信息

这方面你可以直接百度“Drawing2D.Matrix 边缘抗锯齿”

你的Graphics呢,不管怎么转最终肯定是要靠Graphics来实现绘制啊,单纯定义个Matrix 有什么用
Graphics要设置
g.SmoothingMode=SmoothingMode.HighQuality