如何让一个pictureBox图片按照图片中心随鼠标移动旋转

怎么在winform中。如何让一个pictureBox图片按照图片中心随鼠标移动旋转!只旋转不移动!,困在这里好久了

旋转角度通过使用MouseMove事件中的e.X和e.Y和图片中心点位置,使用Math命名空间里的反三角函数计算出来。
然后用下面的代码进行旋转。


        public static Image RotateImage(Image img, float a)
        {
            Bitmap b = new Bitmap(img.Width, img.Height);
            Graphics g = Graphics.FromImage(b);
            g.TranslateTransform((float)b.Width / 2, (float)b.Height / 2);
            g.RotateTransform(a);
            g.TranslateTransform(-(float)b.Width / 2, -(float)b.Height / 2);
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.DrawImage(img, new Point(0, 0));
            g.Dispose();
            return b;
        }