当前位置:编程学习 > C#/ASP.NET >>

关于文本布局

最近用做一个winfrom程序,将文本生成图片,这里就这一个文本的布局问题了(居中,居左,居右),还要考虑到字体的大小(16,24,48),大家有什么好的方法,方便实现吗?
 #region 图片生成Graphics方法
        public void MyGraphics(string text, string color, string bgcolor, string font, int size, string strPath)
        {
            Graphics myGraphics;
            Bitmap myBitmap = new Bitmap(873, 95);
            myGraphics = Graphics.FromImage(myBitmap);
            myGraphics.FillRectangle(new SolidBrush(System.Drawing.ColorTranslator.FromHtml(bgcolor)), 0, 0, 873, 95);
            myGraphics.DrawString(text, new Font(font, size), new SolidBrush(System.Drawing.ColorTranslator.FromHtml(color)),
               new System.Drawing.Point(80, 30));  //这里是绘制的起点
            myBitmap.Save(strPath, ImageFormat.Bmp);
            myGraphics.Dispose();
            myBitmap.Dispose();
        } --------------------编程问答-------------------- 自己顶一下。
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,