基本信息
源码名称:c# 将图片和文字合成到一张图中 实例源码
源码大小:0.02M
文件格式:.zip
开发语言:C#
更新时间:2013-04-23
友情提示:(无需注册或充值,赞助后即可获取资源下载链接)
嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):813200300
本次赞助数额为: 2 元×
微信扫码支付:2 元
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
图片文字 合成实例
/// <summary> /// 应用程序的主入口点。 /// </summary> [STAThread] static void Main() { Application.Run(new Form1()); } public string m_FileName; public Image m_Image; public bool m_Init = false; // 打开图片文件。 private void button1_Click(object sender, System.EventArgs e) { openFileDialog1.Filter = "图形文件(*.bmp;*.jpg;*.jpeg)|*.bmp;*.jpg;*.jpeg"; openFileDialog1.FilterIndex = 1; if(openFileDialog1.ShowDialog() == DialogResult.OK) { m_FileName = openFileDialog1.FileName; m_Image = Image.FromFile(openFileDialog1.FileName); m_Init = true; this.Validate(); } } // 处理窗体显示事件。 private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { if(m_Init) { Rectangle rect = new Rectangle(0,0,this.ClientRectangle.Width, this.ClientRectangle.Height-button1.Height-20); Graphics g = e.Graphics; // 显示图片。 g.DrawImage(m_Image, rect); // 显示图片对应文件名信息。 SolidBrush redBrush = new SolidBrush(Color.Red); g.DrawString(m_FileName, new Font("宋体", 10), redBrush, new Point(0,this.ClientRectangle.Height-30), StringFormat.GenericDefault); } }