【发布时间】:2020-03-05 23:24:41
【问题描述】:
我正在尝试在图像上添加文字,如果文字很短,效果很好。但是,如果我添加更长的文本,它将在边缘被切断。
如果文本太长,我需要换行。
这是我目前的代码:
Graphics graphicImage = Graphics.FromImage(bitMapImage);
//Smooth graphics is nice.
graphicImage.SmoothingMode = SmoothingMode.AntiAlias;
Font font = new Font("Tahoma", 6);
int x_axis = 50;
int y_axis = 120;
int distance = 50;
graphicImage.DrawString("This is a very long text and this long text might come to a new line below", font, Brushes.Yellow, new PointF(x_axis, y_axis + distance * 2));
String tempFile = folder + "output.jpeg";
bitMapImage.Save(tempFile, ImageFormat.Jpeg);
这是它创建的图像
如何让文字换行?
【问题讨论】: