// Instead of using off screen images that may cause some problems
// use Robot to capture canvas 3D image instead of
Point canvas3DOrigin = new Point();
SwingUtilities.convertPointToScreen(canvas3DOrigin, this.canvas3D);
Robot robot = new Robot();
// Render scene with a white background
if (this.iconImageLock != null) {
synchronized (this.iconImageLock) {
setBackground(Color.WHITE);
try {
this.iconImageLock.wait(maxWaitingDelay / 2);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
imageWithWhiteBackgound = robot.createScreenCapture(
new Rectangle(canvas3DOrigin, this.canvas3D.getSize()));
// Render scene with a black background
if (this.iconImageLock != null) {
synchronized (this.iconImageLock) {
setBackground(Color.BLACK);
try {
this.iconImageLock.wait(maxWaitingDelay / 2);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
}
}
imageWithBlackBackgound = robot.createScreenCapture(
new Rectangle(canvas3DOrigin, this.canvas3D.getSize()));
} catch (AWTException ex) {
throw new RuntimeException(ex);
} finally {
this.iconImageLock = null;