winform中 控件上面画的图如何截取
winForm 程序中,button 事件如下:
Image x = new Image.FromFile("d:\\a.bmp");
pictureBox1.CreateGraphics().DrawImage(x,new Rectangle(0,0,x.Width,x.Height));
点击按钮后,form上出现了图像
我现在想要截取CreateGraphics().DrawImage出来的图像中的一部分,请教大家该如何截取?
[解决办法]
Bitmap bit = new Bitmap(x.Width,x.Height);
Graphics ig=Graphics.FromImage(bit);
ig.DrawLine(.......
bit.Save(("d:\\b.bmp");
这样就能把化的图保存下来了
[解决办法]
上面是对2楼的回复。
如果要实现你的功能效果,可以用Picturebox的MouseUp,MouseDown和MouseMove事件,实现选框的效果,并且得到选择框左上角的x,y坐标和选择矩形的width和height,然后调用3楼的方法实现
[解决办法]
http://blog.csdn.net/welcometousebds/article/details/7776093
可以参考这个
[解决办法]
直接用picturebox.CreateGraphics()得到的画布画出的图像不是pictureBox1.Image。
如4楼思路,用图片得到画布对象Graphics ,然后DrawImage出来后,可以将Bitmap赋给pictureBox1.Image,然后就可以获取了。