这种想法应该能实现的,就象5460提交上去的图片全部都在右下角写上了5460
解决方案 »
- C#版编程词典销售分析系统SALE编译出错如何更正
- winform 中播放flash文件 供学习用
- 上一篇下一篇函数中出现:运算符“.”无法应用于“void”类型的操作数
- [求助]关于Split的问题...
- ********* 大家说说知道的 解释 型 的语言。
- 急急急?
- 各位谁做过PNR代码解析
- WCF,帮忙看一下为什么报错
- 关于c#属性的问题
- 怎样遍历一个WebForm上的所有控件。我需要得到一个form上的所有的checkbox控件。并将他们存储起来?
- sqlhelper.cs文件是codesmith中的哪个模板建立的?还是自己编写的?在线急盼回复~~
- 把framework和自己的安装程序,集成为只有一个文件的安装包。
{
if(this.openFileDialog1.ShowDialog()==DialogResult.OK) { if(this.openFileDialog1.FileName.Length==0) { MessageBox.Show("请选择图片","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); return; } this.textBox1.Text=this.openFileDialog1.FileName; FileStream fs=new FileStream(this.openFileDialog1.FileName,FileMode.Open,FileAccess.Read); try { this.pictureBox1.Image=Image.FromStream(fs);
} catch(Exception) { MessageBox.Show("您选择的文件不是可识别的图片格式","错误",MessageBoxButtons.OK,MessageBoxIcon.Error); } finally { fs.Close(); } }
} private void Form1_Load(object sender, System.EventArgs e)
{
} private void button2_Click(object sender, System.EventArgs e)
{
int height,width;
height = this.pictureBox1.Image.Height;
width = this.pictureBox1.Image.Width;
Bitmap bitmap=new Bitmap(width,height,System.Drawing.Imaging.PixelFormat.Format24bppRgb); //根据位图获取画布 Graphics g=Graphics.FromImage(bitmap); //清空画布并用透明色填充 g.Clear(Color.Transparent); //将另一幅图片画到画布上
MessageBox.Show(height.ToString() + " " + width.ToString());
Rectangle rc = new Rectangle(0,0,width,height);
g.DrawImage(this.pictureBox1.Image,rc); //写版权信息到图片上。 g.DrawString(this.textBox2.Text,new Font("黑体",40),new SolidBrush(Color.Red),new Rectangle(20,20,300,300)); //显示 this.pictureBox2.Image=bitmap;
this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage; //保存图片 bitmap.Save("c:\\abc.jpg",System.Drawing.Imaging.ImageFormat.Jpeg);
MessageBox.Show(this.pictureBox2.Image.Height.ToString() + " " + this.pictureBox2.Image.Width.ToString());
this.pictureBox3.Image = this.pictureBox1.Image;
}
}
try
{
if(dialog.ShowDialog() == DialogResult.OK)
{
Image image = Image.FromFile(dialog.FileName);
Graphics g = Graphics.FromImage(image);
g.DrawString("1234567",this.Font,Brushes.White,10,10);
image.Save("1234567.jpg",ImageFormat.Jpeg);
g.Dispose();
image.Dispose();
}
}
catch (Exception e1)
{
MessageBox.Show(e1.Message);
}