C# gdi+ 如何让字体旋转

Bitmap bTextBmp = new Bitmap(20, 50);
Graphics gphText = Graphics.FromImage(bTextBmp);

        gphText.TranslateTransform(10, 25);//平移到适当的位置,以便下面旋转后可以显示
        gphText.RotateTransform(90);//旋转角度,以达到你要的效果
       // gphText.DrawString("counts", new Font("Times New Roman", 12, FontStyle.Regular), Brushes.Black, new PointF(10, 0));
        StringFormat format = new StringFormat(StringFormatFlags.NoClip);
        format.Alignment =StringAlignment.Center;
        format.LineAlignment = StringAlignment.Center;
        gphText.DrawString("Counts ", new Font("Times New Roman", 12, FontStyle.Regular), Brushes.Black, 0, 0, format);


        pictureBox2.Image = bTextBmp;



                    主要是想做y坐标轴的标注,这样是可以旋转,但是字体变形,有没有更好的方法,或者,如何写才正确。谢谢。就是想画一个简单的折线图。。

你直接旋转画布,graphic有几个translate相关的方法,旋转画布,不用你再计算坐标了

如果是旋转90度,在字体名前加上@
比如@Times New Roman
就可以了。

    private void Form1_Paint(object sender, PaintEventArgs e)
    {
        e.Graphics.DrawLine(Pens.Red, 0, 0, 100, 0);
        e.Graphics.RotateTransform(20);
        e.Graphics.DrawLine(Pens.Red, 0, 0, 100, 0);
        e.Graphics.RotateTransform(20);
        e.Graphics.DrawLine(Pens.Red, 0, 0, 100, 0);
    }