这种想法应该能实现的,就象5460提交上去的图片全部都在右下角写上了5460

解决方案 »

  1.   

    private void button1_Click(object sender, System.EventArgs e)
    {
    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;
    }
    }
      

  2.   

    OpenFileDialog dialog = new OpenFileDialog();
    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);
    }