当前位置: 移动技术网 > IT编程>开发语言>c# > C#实现在图像中绘制文字图形的方法

C#实现在图像中绘制文字图形的方法

2019年07月18日  | 移动技术网IT编程  | 我要评论

本文实例讲述了c#实现在图像中绘制文字图形的方法。分享给大家供大家参考。具体实现方法如下:

using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.drawing.drawing2d;
using system.drawing.imaging;
namespace windowsapplication2
{
  public partial class form20 : form
  {
    public form20()
    {
      initializecomponent();
    }
    private void form20_load(object sender, eventargs e)
    {
    }
    private void button1_click(object sender, eventargs e)
    {
      rectangle rect = new rectangle(0, 0, 100, 100);
      graphics dg = this.creategraphics();
      image image = new bitmap(rect.width, rect.height, dg);
      graphics ig = graphics.fromimage(image);
      ig.fillrectangle(brushes.black, rect);
      font font = new font("arial", 12);
      brush brush = system.drawing.brushes.white;
      ig.drawstring("zhuzhao", font, brush,0, 0);
      //imageformat iformat=new imageformat(new guid(bmp));
      image.save(@"c:/image.png");
      dg.drawimage(image,new pointf(100,100));
    }
  }
}

希望本文所述对大家的c#程序设计有所帮助。

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网