C# 怎么给图片增加白底黑字 Image bmp = Bitmap.FromStream(ms, true);
int iHeight = bmp.Height;
int iWidth = bmp.Width;
Graphics g = Graphics.FromImage(bmp);
g.DrawString(sDesc1, new Font("宋体", 32, FontStyle.Bold), Brushes.White, new PointF(10, 20));
g.DrawString(sDesc2, new Font("宋体", 32, FontStyle.Bold), Brushes.White, new PointF(10, iHeight - 150));
ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);这里文字是加上去了,但是怎么增加底色呢?????
int iHeight = bmp.Height;
int iWidth = bmp.Width;
Graphics g = Graphics.FromImage(bmp);
g.DrawString(sDesc1, new Font("宋体", 32, FontStyle.Bold), Brushes.White, new PointF(10, 20));
g.DrawString(sDesc2, new Font("宋体", 32, FontStyle.Bold), Brushes.White, new PointF(10, iHeight - 150));
ms = new MemoryStream();
bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);这里文字是加上去了,但是怎么增加底色呢?????
你这个画的不就是白字吗增加白底可以取得字符的长度和高度,画一个白色的区域来容纳字符,取得字符像素长度或者高度的代码如下
int dStrLength = Convert.ToInt32(Math.Ceiling(this.CreateGraphics().MeasureString(textbox1.text, textbox.font).Width))