在图像上绘制点
我有一张图像,需要在其上绘制一些点。问题是这些点只出现几分之一秒,然后就消失了。如何使点永久显示在图像上。我已将图像设置为表单的背景。
我正在研究 C# .net 框架。 谢谢。
I've an image over which i need to plot some points. The problem is that the points appear for a fraction of a second and then disappear. How to make the points permanent over the image. I've set the image as the background of the form.
I'm working on C# .net framework.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以为图像创建一个 Graphics 对象,然后在图像上绘制这些点。这确实使它们永久存在。就像这样:
这将从左上角到右下角绘制一条 AliceBlue 线。
You could create a Graphics object for the image and then draw these points on the image. That make them permanent indeed. Like so:
That will draw an AliceBlue line from the top left corner to the bottom right corner.
我们需要查看代码。我的猜测是,您正在使用 CreateGraphics 进行绘制,而不是在 OnPaint 中进行绘制,因此当重新绘制控件时,它会被简单地擦除,并且您再也不会绘制它。覆盖 OnPaint 并在那里完成所有绘图(或发布相关示例)
We need to see code. My guess would be that you are drawing using CreateGraphics and not doing so in OnPaint, so it is simply wiped out when the control is repainted and you never paint it again. Override OnPaint and do all of your drawing there (or post a relevant example)
在您的情况下,只需将点绘制代码放入表单的 OnPaint 事件处理程序中即可。由于表单重绘例程,您的积分消失了
In your case just put your point plotting code to
OnPaint
event handler of the form. Your points dissapears because of form repaint routine