C#GDI绘图流程

using System.Drawing;
using System.Drawing.Imaging;
using System.Drawing.Text;
引入命名空间
    string path = Server.MapPath(@"~/images/jbbjtu.jpg");//得到图片的路径
System.Drawing.Image imgSrc = System.Drawing.Image.FromFile(path);
Font font = new Font("宋体", 12);//字体大小;
      SolidBrush solid = new SolidBrush(Color.Black);//字体颜色
      Graphics g = Graphics.FromImage(imgSrc);
Pen le = new Pen(Color.Black,1);//定义画笔
      Rectangle line_Rect = new Rectangle(xnum-Convert.ToInt32(jp_lt_rt)+10, peny1, font_w, font_h);//范围
      g.DrawString(dai_name, font, solid, line_Rect); //得到家族的名字
      g.DrawLine(le, new Point(xnum-Convert.ToInt32(jp_lt_rt)  , peny1+ Convert.ToInt32(jp_up_dw)/2 ),new Point(penx2+2800, peny1+Convert.ToInt32(jp_up_dw)/2));
      g.DrawLine(le, new Point(xnum -10 , peny1-Convert.ToInt32(jp_up_dw)), new Point(xnum - 10, peny1+Convert.ToInt32(jp_up_dw)));
/**得到URL的图片地址**/
      System.Net.WebClient client = new System.Net.WebClient();
      Stream stream = client.OpenRead(no1path);
      System.Drawing.Image img_logo = System.Drawing.Image.FromStream(stream);
/**end**///加载本地的图片
   
 System.Drawing.Image img_logo = System.Drawing.Image.FromFile(no1path);
/*绘制图片*/
 Rectangle drawRect = new Rectangle(no1x,no1y, font_w, font_h);
Rectangle drawrect2 = new Rectangle(no1x2,no1y2,font_w,font_h);
g.DrawImage(img_juxing, new Rectangle(xnum, iy, img_juxing.Width, img_juxing.Height), 0, 0, img_juxing.Width, img_juxing.Height, GraphicsUnit.Pixel);//得到矩形;
g.DrawImage(img_logo,xnum,iy,logo_w,logo_h);
g.DrawString(no1name, font, solid, drawRect); //得到家族的名字
g.DrawString(no1birthday, font, solid, drawrect2);//得到家族代的生日
//最后记的释放内存

     g.Dispose();
     imgSrc.Dispose();
     Img_jiapu.Dispose();
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值