如何将整个可滚动画布另存为 PNG?
我有一个可滚动的画布,我想要将其内容放入 png 图像中。
问题是我只得到了画布的照片,缺少画布在给定时间的不可见部分。
如何将整个可滚动画布转换为 png 图像?
我当前的代码如下:
my $canvas_to_get_photo=$mw->Photo(-format=>'Window', -data=>oct($canvas_to_get->id));
$canvas_to_get_photo->write('somepath/image.png', -format=>'png');
I have a scrollable canvas who's content i want into a png image.
The problem is I only get a photo of the canvas, missing the non visible part of the canvas at that given time.
How do i get the whole scrollable canvas into a png image?
My current code is the following:
my $canvas_to_get_photo=$mw->Photo(-format=>'Window', -data=>oct($canvas_to_get->id));
$canvas_to_get_photo->write('somepath/image.png', -format=>'png');
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
没有一种本地方法可以做到这一点; Tk 仅绘制窗口,而不绘制基于图像的表面。因此,您的选择是:
There isn't a native way to do it; Tk only paints to windows, not to image-based surfaces. Your options are therefore to either:
我已经有一段时间没有做过任何繁重的 Tk 工作了,所以这可能行不通。您是否尝试过寻找滚动画布的非滚动子组件。
IIRC,每个“滚动”小部件实际上是一个“大型小部件”,带有滚动条、角项和滚动项子小部件。
所以,这可能是你想要的
It's been a awhile since I did any heavy Tk work, so this may not work. Have you tried looking for the non-scrolled subcomponent of the scrolled canvas.
IIRC, each 'Scrolled' widget is actually a "mega-widget", with scrollbars, a corner item, and a scrolled item sub-widgets.
So, it may be that you want