如何隐藏 SWT 浏览器或在无头模式下运行? [英] How to hide SWT Browser or run in headless mode?

查看:39
本文介绍了如何隐藏 SWT 浏览器或在无头模式下运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从 SWT 浏览器中取出呈现的页面并将其导出为图像.我的问题是,当外壳不可见时,我无法正确导出它.如何隐藏浏览器并正确导出图像?

I took the rendered page from the SWT Browser and exported it to an image. My problem is that I am not able to get it to export properly when the shell is not visible. How can I go about hiding the browser and have the image export properly?

我曾尝试将 shell.Visible() 设置为 false,但这会弄乱图像导出.

I have tried setting shell.Visible() to false but that messes up the image export.

这就是我导出图像的方式(不确定这对问题是否必要):

This is how I export the image (not sure if this is necessary to the question):

GC source = new GC (shell);  
Image image = new Image(display, browser.getClientArea()); 
source.copyArea(image, 0, 0);
ImageLoader io = new ImageLoader ();
io.data = new ImageData[] { image.getImageData() };
File f = new File (currentDir+"/workpng.png");
io.save (f.getAbsolutePath(), SWT.IMAGE_PNG); 

推荐答案

这可能是不可能的,因为当窗口不可见时,X 服务器/Windows 将丢弃所有渲染命令(渲染你看不到的东西毫无意义)见).

This might be impossible because the X server/Windows will throw away all rendering commands when the window isn't visible (no point in rendering what you can't see).

在这种情况下,浏览器的客户区是什么?

Also what is the client area of the browser in this case?

要完成这项工作,您需要允许打开的外壳可见(即不被其他窗口隐藏).像 Jenkins 这样的工具使用一个插件来启动 X 会话与 XvfbXvnc.设置环境变量 DISPLAY 后,所有 UI 渲染都将转到这些会话.

To make this work, you'll need to allow the shell to open be visible (i.e. not hidden by some other window). Tools like Jenkins use a plugin that starts an X session with Xvfb or Xvnc. After setting the env variable DISPLAY, all UI rendering goes to these sessions.

这篇关于如何隐藏 SWT 浏览器或在无头模式下运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆