c# 绘图常用对象和方法

 //BitMap 位图,常用的方法,
     Save:主要方式有:(1)保存在图像文件里,可以指定格式[gif,bmp];(2) 保存在流中,以指定格式[gif,bmp]
        
 //graphic图像操作对象
    画图片的边框线 
      graphic.DrawRectangle(new Pen(Color.Silver), 0, 0, image.Width - 1, image.Height - 1);
    画文本
       Font font = new Font("Arial", 12, (FontStyle.Bold | FontStyle.Italic));
       LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, image.Width, image.Height), Color.Red, Color.DarkRed, 1.2f, true);
       graphic.DrawString(checkCode, font, brush, 2, 2);//文本字符串 用刷子brush 字体font 区域Rectangle
    画图片的前景噪音点 
        for (int i = 0; i < 100; i++)
      {
         x = random.Next(image.Width);
        y = random.Next(image.Height);

        image.SetPixel(x, y, Color.FromArgb(random.Next()));
      }
   画线
      graphic.DrawLine(new Pen(Color.Silver), x1, y1, x2, y2);//线用画笔

posted @ 2013-07-22 21:48  youhumian  阅读(388)  评论(0编辑  收藏  举报