G.DrawString 文字换行.

源自"博问",GDI+ 中如何DrawString多行文本? 

我的实现方式,用数组,然后坐标定位.

 

Code
  Bitmap bt1 = new Bitmap(300350, PixelFormat.Format24bppRgb);
            Graphics g 
= Graphics.FromImage(bt1);
            //g.DrawString(
@"你好,\r\n cnblogs.com"new Font(FontFamily.GenericSansSerif, 22), 
                //
new SolidBrush(Color.White), 3230, StringFormat.GenericDefault);
            String[] strings 
= new string[] { "你好""cnblogs.com" };
            Point p 
= new Point(00);
            
foreach (string s in strings)
            {
                p.Y 
= p.Y + 30;
                g.DrawString(s, 
new Font(FontFamily.GenericSansSerif, 22), 
                    
new SolidBrush(Color.White), p.X, p.Y, StringFormat.GenericDefault);
            }
            bt1.Save(
"123.jpg", ImageFormat.Jpeg);

 

如有其他优化方案或解决办法,欢迎交流.

转载请注明原文地址:http://www.cnblogs.com/winzheng/archive/2009/03/05/1403992.html

 

 

posted @ 2009-03-05 16:39  winzheng  阅读(5932)  评论(3编辑  收藏  举报