一段字符串中可能既有汉字又有字母,对于汉字和字母分别采用不同的字体进行绘制直接po代码了
Bitmap bmp = new Bitmap(iWidth, iHeight);
Graphics g = Graphics.FromImage(bmp);
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
g.FillRectangle(new SolidBrush(Color.FromArgb(0, 90, 169)), new Rectangle(0, 0, bmp.Width, bmp.Height));
if (IFYY)
{
Font arial = new System.Drawing.Font("Arial", 46F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
StringFormat test = StringFormat.GenericTypographic;
SizeF size = g.MeasureString(strText, font, 1062, test);
float fX = (1062 - size.Width) / 2 +