小编Nol*_*dge的帖子

围绕中心 C# 旋转图像

尝试在图片框中旋转图像时出现小错误。这一切都有效。但是在旋转时,它不会完美地围绕中心旋转。它略微偏离(不是很明显)但有点烦人。这是我的代码:

private readonly Bitmap _origPowerKnob = Properties.Resources.PowerKnob;

//CODE WHERE ROTATE METHOD IS CALLED//

using (Bitmap b = new Bitmap(_origPowerKnob))
                {
                    Bitmap newBmp = RotateImage(b, _powerAngle);
                    PowerKnob.BackgroundImage = newBmp;
                }

private Bitmap RotateImage(Bitmap b, float angle)
        {
            //Create a new empty bitmap to hold rotated image.
            Bitmap returnBitmap = new Bitmap(b.Width, b.Height);
            //Make a graphics object from the empty bitmap.
            Graphics g = Graphics.FromImage(returnBitmap);
            //move rotation point to center of image.
            g.InterpolationMode = InterpolationMode.HighQualityBicubic;
            g.TranslateTransform((float) b.Width / 2, (float)b.Height / 2); …
Run Code Online (Sandbox Code Playgroud)

c# rotation picturebox

1
推荐指数
1
解决办法
8892
查看次数

标签 统计

c# ×1

picturebox ×1

rotation ×1