对 Control.DrawToBitmap 的父级调用似乎不尊重子控件中设置的剪切区域
我创建了一个 UserControl,它简单地定义了一个新的 GraphicsPath 并将其设置为控件的区域。它的主要用途是充当其他控件的背景,因此通常在其上设置的唯一内容是 BackColor。当我在控件的父控件上调用 DrawToBitmap 时,子控件将绘制为矩形,而不是剪切到我期望的区域。我在这里错过了什么吗?
标准使用该控件不会出现此问题。
另外,我需要能够将此控件绘制到当前未显示在屏幕上的图像上。我已经看到,如果没有这个额外的要求,一些解决方法可能会起作用。
I have created a UserControl which simply defines a new GraphicsPath and sets that to be the Region of the control. Its primary use is to act as a backdrop for other controls so typically the only thing set on it is BackColor. When I call DrawToBitmap on the control's parent, the child control is drawn as a rectangle rather than getting clipped to region I expected. Am I missing something here?
Standard use of the control does not exhibit this problem.
Also, I need to be able to draw this control to an image while it is not currently shown on screen. I have seen some workarounds would could have worked had I not had this additional requirement.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
DrawToBitmap 不支持区域。但是 Graphics.CopyFromScreen 是这样。
DrawToBitmap does not honor regions. But Graphics.CopyFromScreen does.