0

我在 Eclipse 插件中有以下代码来截取屏幕截图并显示图像的两个副本。将来,我将对第二个副本进行一些修改,但现在只显示一个精确的副本就足够了。但是,第二个副本显示为空白。

看起来这screenshot.getImageData().data是一个由 0 和 -1 组成的数组:[0, -1, -1, -1, 0, -1, -1, -1, ... ]

任何想法可能导致第二张图像为空白或我应该尝试什么?

谢谢

// Take a screenshot
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
Shell shell = window.getShell();
Display display = shell.getDisplay();

Rectangle windowBounds = shell.getBounds();

GC gc = new GC(display);
Image screenshot = new Image(display, windowBounds);
gc.copyArea(screenshot, windowBounds.x, windowBounds.y);
gc.dispose();


// Display the images
Composite container = (Composite) super.createDialogArea(parent);
container.setLayout(new GridLayout(1, false));
container.setBackground(new Color(Display.getDefault(), 255, 255, 0));

new Label(container, SWT.NONE).setImage(screenshot);

// Copy of screenshot. To be scaled down at a later time
Image scaledSS = new Image(screenshot.getDevice(), screenshot.getImageData());

new Label(container, SWT.NONE).setImage(scaledSS);

在此处输入图像描述

4

0 回答 0