Bitmap bt1 = new Bitmap(300,350,PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bt1);
g.DrawString("你好 cnblogs.com",font,new SolidBrush(Color.White),10,10);
//g.Clear(Color.White);
bt1.Save("123.jpg",ImageFormat.Jpeg);
如何实现输出为:
你好
cnblogs.com
1.只能根据坐标,调整成两行了.
http://www.cnblogs.com/winzheng/archive/2009/03/05/1403992.html
Code
Bitmap bt1 = new Bitmap(300, 350, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bt1);
String[] strings = new string[]{"你好","cnblogs.com"};
Point p = new Point(0,0);
foreach (string s in strings)
{
p.Y = p.Y + 30;
g.DrawString(s, font, new SolidBrush(Color.White), p.X,p.Y, StringFormat.GenericDefault);
}
//g.Clear(Color.White);
bt1.Save("123.jpg", ImageFormat.Jpeg);
把字符串改成"你好\r\ncnblogs.com"
如果要是说是根据你输入的长度进行转行的话,就要用g.MeasureString计算的