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 property. To save the 3D window to a file, call the SaveToFile method, as shown below:

Scene.Camera.Snapshot.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.

Raster image = Scene.Camera.Snapshot.SaveToRaster();

BrightnessFilter brightness = new BrightnessFilter
    Adjustment = 0.5

TextureScreenOverlay overlay = new TextureScreenOverlay(0, 0, image.Attributes.Width / 2, image.Attributes.Height / 2);
Texture2D texture2D = SceneManager.Textures.FromRaster(image);
overlay.Texture = texture2D;

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:

Scene.Camera.Snapshot.SaveToFile(fileName, CameraSnapshotFileFormat.Jpeg, 6, 360);