在图像上绘制粗体字符串 [英] Draw Bold string on an image

查看:93
本文介绍了在图像上绘制粗体字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想画一个像我叫 Tom 的刺,人们在图像中我.但是我不知道如何,任何人都可以帮助我.我想在格式文本框中复制一个格式化的长文本,然后将其写在image.so上,所以我需要在一个矩形中对齐它.有人知道这样做的简单方法吗?
我的代码:

i want to draw a sting like my name is Tom and people love me in an image.but i don''t know how, can anyone help me. i want to copy a formatted long text in a richtext box and after that write it on an image.so i need to align that in a rectangle.do anyone know the simple way to do this?
my code:

imgInput = bmpinput;
            grfInput = Graphics.FromImage(imgInput);
     SolidBrush drawBrush = new SolidBrush(Color.Black);
            StringFormat drawFormat = new StringFormat();
            drawFormat.FormatFlags = StringFormatFlags.FitBlackBox;
            drawFormat.Alignment = StringAlignment.Center;
  grfInput.DrawString(ord.q1,new Font("Arial",x,FontStyle.Regular,GraphicsUnit.Pixel), drawBrush, new RectangleF(0, 0,877/3, 620/8 ), drawFormat);

推荐答案

图形类不会采用富文本格式.您需要自己放置粗体字并使其变粗.您可以使用Graphics.MeasureString找出一个单词的结尾,然后将另一个单词加粗.
The graphics classes won''t take rich text. You need to position the bold words yourself and make them bold. You can use Graphics.MeasureString to work out where one word ends to put the next one in bold.


请参见此处的示例..
http://www.devasp.net/net/articles/display/1084.html [ ^ ]
http://stackoverflow.com/问题/5543988/how-to-draw-a-rotated-string-as-an-image-with-system-drawing [ http://www.daniweb.com/software-development/csharp/threads/393652/drawing-text-to-image-quality [
See some example from here..
http://www.devasp.net/net/articles/display/1084.html[^]
http://stackoverflow.com/questions/5543988/how-to-draw-a-rotated-string-as-an-image-with-system-drawing[^]
http://www.daniweb.com/software-development/csharp/threads/393652/drawing-text-to-image-quality[^]


这篇关于在图像上绘制粗体字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆