點出來的點無法隨圖片保存下來,求助大神啊
下面是代碼
public Form1()
{
InitializeComponent();
m_lsPoints = new List();
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Graphics g = ((PictureBox)sender).CreateGraphics();
g.FillEllipse(Brushes.Red, e.X, e.Y, 4, 4);
Point pt = new Point(e.X, e.Y);
m_lsPoints.Add(pt);
g.Dispose();
int x = e.X;
int y = e.Y;
richTextBox1.AppendText ("(" + x + "," + y + ")"+"\r\n");
}
private void button3_Click(object sender, EventArgs e)
{
#region 保存圖片
Bitmap bmp = new Bitmap(pictureBox1.Image, pictureBox1.Width, pictureBox1.Height);
Graphics g = Graphics.FromImage(bmp);
bmp.Save("d://1.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
#endregion
}
記錄下點集合,在
Graphics g = Graphics.FromImage(bmp);
後面根據記錄的點,繪圖,即把你pictureBox1_MouseDown繪圖的代碼放在下面