Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/visual-studio-code/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Swt GC#无头模式下的复印区_Swt - Fatal编程技术网

Swt GC#无头模式下的复印区

Swt GC#无头模式下的复印区,swt,Swt,我创建了一个控件来显示图像,为了测试它,我创建了该控件的“屏幕截图”,并将其与我期望的结果进行比较。SReenshot的创建方式如下: protected Image createScreenshot(Control control) { final GC gc = new GC(control); try { final Point size = control.getSize(); final Image result = new Image(

我创建了一个控件来显示图像,为了测试它,我创建了该控件的“屏幕截图”,并将其与我期望的结果进行比较。SReenshot的创建方式如下:

protected Image createScreenshot(Control control) {
    final GC gc = new GC(control);
    try {
        final Point size = control.getSize();
        final Image result = new Image(control.getDisplay(), size.x, size.y);
        gc.copyArea(result, 0, 0);
        return result;
    } finally {
        gc.dispose();
    }
}
从IDE启动时效果很好,但从CI服务器以无头模式启动时,图像不会呈现。我试着给周围的
Shell
拍照,但是
Shell
的屏幕截图也是白色的

我尝试了以下方法来让屏幕截图正常工作:

    Control#redraw();
    Control#update();
它们不起作用


有没有办法在无头模式下渲染控件?

我怀疑控件没有绘制在屏幕上,这就是为什么会看到空白图像

我认为你的问题与此类似:

要解决此问题,您应遵循以下链接:

祝你好运