是 windows 程序还是 web ? 你写的那个名字要写在图上 给你写一个 windows 程序的要web的原理一样控件 pictureBox1 textBox1 自己放置、图片自自己改代码 这个代码就是个原理性的、如果要保存到数据库还需要一个表记住点位、点的类型等信息、还有记号的形状等using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms;namespace WindowsApplication2 { public partial class Form1 : Form { Dictionary<Point,string> res = new Dictionary<Point,string>(); public Form1() { InitializeComponent();
你写的那个名字要写在图上
给你写一个 windows 程序的要web的原理一样控件
pictureBox1
textBox1
自己放置、图片自自己改代码
这个代码就是个原理性的、如果要保存到数据库还需要一个表记住点位、点的类型等信息、还有记号的形状等using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace WindowsApplication2
{
public partial class Form1 : Form
{
Dictionary<Point,string> res = new Dictionary<Point,string>();
public Form1()
{
InitializeComponent();
this.textBox1.BorderStyle = BorderStyle.None;
this.textBox1.Parent = pictureBox1;
this.textBox1.ImeMode = ImeMode.On;
this.textBox1.Visible=false;
this.pictureBox1.ImageLocation="01.jpg";
} private void pictureBox1_Click(object sender, EventArgs e)
{
} private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
this.textBox1.Location = e.Location;
this.textBox1.Visible = true;
this.textBox1.Focus();
} private void textBox1_KeyDown(object sender, KeyEventArgs e)
{
TextBox txtBox = sender as TextBox;
if(e.KeyCode == Keys.Enter)
{
res.Add(txtBox.Location,txtBox.Text.Trim());
txtBox.Text="";
txtBox.Visible=false;
pictureBox1.Invalidate();
}
} private void pictureBox1_Paint(object sender, PaintEventArgs e)
{
Graphics g= e.Graphics;
foreach(KeyValuePair<Point,string> kv in res)
{
g.DrawString(kv.Value,this.Font,Brushes.Red,kv.Key.X,kv.Key.Y);
}
}
}
}
这个画笔工具做得不错,支持修改、撤销、重复
楼主可以参考一下,虽然现在没有文字工具
注释就用2楼说的Graphic对象的DrawString方法。可以在你显示图片的容器,比如PictureBox的Paint方法中用PictureBox的Graphic对象,也可以在任意时候用Graphic类的静态方法FromImage获得Bitmap对象的Graphic。前者是在PictureBox上画,不影响图片,后者直接画在图片上,如果保存的话会连画上去的内容一块保存。如果不保存就没什么区别。