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);这里文字是加上去了,但是怎么增加底色呢?????

解决方案 »

  1.   

    先FillRectangle,填充一个矩形,再在上面画字符串
      

  2.   

     g.DrawString(sDesc1, new Font("宋体", 32, FontStyle.Bold), Brushes.White, new PointF(10, 20));
    你这个画的不就是白字吗增加白底可以取得字符的长度和高度,画一个白色的区域来容纳字符,取得字符像素长度或者高度的代码如下
    int dStrLength = Convert.ToInt32(Math.Ceiling(this.CreateGraphics().MeasureString(textbox1.text, textbox.font).Width))
      

  3.   

    底色 FillRectangle,填充区域,然后再写字
      

  4.   

    Quote:
    先FillRectangle,填充一个矩形,再在上面画字符串  
    Quote:
      

  5.   

    [quote ]先FillRectangle,填充一个矩形,再在上面画字符串  aa