Click or drag to resize

Taking Snapshots

Insight3D provides methods to take snapshots, or screenshots, of the 3D window.

Taking Snapshots

Snapshots of the 3D window are taken by using a CameraSnapshot object, which is accessible from the Snapshot (get) property. To save the 3D window to a file, call the saveToFile method, as shown below:

Java
getScene().getCamera().getSnapshot().saveToFile(fileName, CameraSnapshotFileFormat.JPEG);

The resulting image will have the same width and height as the 3D window. Snapshots can also be copied to the clipboard by calling the saveToClipboard method. Raster objects can be created from snapshots by calling the saveToRaster method. Creating a Raster allows the snapshot to be processed using Insight3D's imaging capabilities, as discussed in the Imaging topic. Furthermore, a texture can be created from the image and used with a primitive, screen overlay, or ProjectedRaster. The following example creates an image from a snapshot, brightens it, and then creates a texture screen overlay based on the image.

Java
Raster image = getScene().getCamera().getSnapshot().saveToRaster();

BrightnessFilter brightness = new BrightnessFilter();
brightness.setAdjustment(0.5);
image.applyInPlace(brightness);

TextureScreenOverlay overlay = new TextureScreenOverlay(0.0, 0.0, image.getAttributes().getWidth() / 2, image.getAttributes().getHeight() / 2);
Texture2D texture2D = SceneManager.getTextures().fromRaster(image);
overlay.setTexture(texture2D);

SceneManager.getScreenOverlays().add(overlay);
Snapshot as Texture Overlay
Taking High Resolution Snapshots

By default, snapshots taken by calling saveToFile, saveToClipboard, and saveToRaster use the same resolution as the 3D window.

For some uses, such as printing, a higher resolution is needed. To take a high resolution snapshot, the saveToFile method has an overload taking additional parameters, defined in terms that printers typically use: width in inches and dots per inch. Multiplying the two together produces the actual width of the snapshot in pixels. The height of the snapshot is based on that width and the aspect ratio of the 3D window's width and height.

The following example saves a high resolution snapshot to a file:

Java
getScene().getCamera().getSnapshot().saveToFile(fileName, CameraSnapshotFileFormat.JPEG, 6.0, 360.0);