单击图片里,图片被更改,但是,保存后竟然还是原图,高手出来指教呀。 private void 涂抹_Load(object sender, EventArgs e)
{
pictureBox1.Image = ig;
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Cursor.Current = new Cursor(@"c:\windows\cursors\cross_r.cur");//自定义鼠标形状
Graphics gr = pictureBox1.CreateGraphics();
Rectangle sour = new Rectangle(e.X - 10, e.Y - 10, 20, 20);//要放大的区域参数里面是位置和大小
Rectangle des = new Rectangle(e.X - 20, e.Y - 20, 40, 40);
gr.DrawImage(pictureBox1.Image, des, sour, GraphicsUnit.Pixel);
}
{
pictureBox1.Image = ig;
}
private void pictureBox1_MouseDown(object sender, MouseEventArgs e)
{
Cursor.Current = new Cursor(@"c:\windows\cursors\cross_r.cur");//自定义鼠标形状
Graphics gr = pictureBox1.CreateGraphics();
Rectangle sour = new Rectangle(e.X - 10, e.Y - 10, 20, 20);//要放大的区域参数里面是位置和大小
Rectangle des = new Rectangle(e.X - 20, e.Y - 20, 40, 40);
gr.DrawImage(pictureBox1.Image, des, sour, GraphicsUnit.Pixel);
}
应该将更改保存到一个Bitmap对象中。
Cursor.Current = new Cursor(@"c:\windows\cursors\cross_r.cur");//自定义鼠标形状
Bitmap bitmap = new Bitmap(pictureBox1.Image);
Graphics gr = Graphics.FromImage(bitmap);
Rectangle sour = new Rectangle(e.X - 10, e.Y - 10, 20, 20);//要放大的区域参数里面是位置和大小
Rectangle des = new Rectangle(e.X - 20, e.Y - 20, 40, 40);
gr.DrawImage(pictureBox1.Image, des, sour, GraphicsUnit.Pixel);
pictureBox1.Image = bitmap;