I have this piece of code that worked throug the ages (kepler to oxygen) for the last 4 Years,
Since the Windows 10 1809 update this results in an all black picture. This happens on several PCs.
public static Image renderToImage(Control control) {
Shell imgShell = new Shell(control.getDisplay(), SWT.NO_TRIM);
Composite oldParent = control.getParent();
Point size = control.getSize();
imgShell.setSize(size);
control.setParent(imgShell);
Image image = new Image(control.getShell().getDisplay(), size.x, size.y);
GC gc = new GC(image);
//gc.setForeground(imgShell.getDisplay().getSystemColor(SWT.COLOR_RED));
//gc.drawString("Image",size.x/2, size.y/2, true);
control.print(gc);
gc.dispose();
control.setParent(oldParent);
return image;
}
I updated my application from oxygen to eclipse-rcp-1903 and this problem persists.
The gc.drawString line works and will write the words "Image" onto the Image.
The following screenshot shows the problem. The black area is supposed to be an Image that was copied from a shell that looks like the one below it.