我正在使用SWT截取当前活动的Eclipse shell的屏幕截图。我到目前为止所做的一般都在工作,但是图像以72 ppi的速度保存,而且我需要比这更好的分辨率。我怀疑质量的损失与copyArea方法有关,因为API声明它必须复制到位图Image,但我找不到更多关于此的信息。
如何以更高的分辨率保存图像?如果需要,我愿意采取完全不同的方法。
道歉,如果我忽略了一些明显的东西,我仍然是一个新手。
Display display = PlatformUI.getWorkbench().getDisplay();
Shell shell = display.getActiveShell();
// Take the screenshot
GC gc = new GC(display);
Rectangle eclipseWindow = shell.getBounds();
Image screenshot = new Image(display, eclipseWindow);
gc.copyArea(screenshot, eclipseWindow.x, eclipseWindow.y);
gc.dispose();
// code that creates a file name and gets the file path omitted
String imgFilePath = "imgFilePath";
// save the screenshot as a png
ImageLoader imgLoader = new ImageLoader();
imgLoader.data = new ImageData[] { screenshot.getImageData() };
imgLoader.save(imgFilePath, SWT.IMAGE_PNG);
screenshot.dispose();