How to hide SWT Browser or run in headless mode?

核能气质少年 提交于 2019-12-25 05:14:40

问题


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?

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); 

回答1:


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?

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.



来源:https://stackoverflow.com/questions/11157301/how-to-hide-swt-browser-or-run-in-headless-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!