| Topic | Description |
|---|---|
| Taking Snapshots | AgGxCameraSnapshot is used to take snapshots of the 3D window. |
| Taking High Resolution Snapshots | Describes how to take snapshots that are a higher resolution than the 3D window. |
| Anti-aliasing | Anti-aliasing can be used to smooth sharp edges. |
Snapshots of the current contents of the 3D window are taken by use the camera's Snapshot interface. To save the 3D window to a file, use SaveToFile as shown below.
scene.Camera.Snapshot.SaveToFile(@"C:\snapshot.jpg", AgGxCameraSnapshotFormat.CameraSnapshotFormatJPEG);
The resulting image will have the same width and height as the 3D window. Snapshots can also be copied to the clipboard using SaveToClipboard. Furthermore, AgGxImage objects can be created from snapshots using SaveToImage. Creating an AgGxImage object allows the snapshot to be processed using Insight3D's imaging capabilities. Furthmore, a texture can be created from the image and used as input to a primitive, overlay, or projected image globe inlay. The following example creates an image from a snapshot, brightens it, and then creates a texture overlay based on the image.
IAgGxImage image = scene.Camera.Snapshot.SaveToImage(); IAgGxConditionerBrightness brightness = new AgGxConditionerBrightness(); brightness.Adjustment = 0.5; image.ApplyInPlace(brightness); IAgGxOverlayTexture overlay = new AgGxOverlayTexture(); overlay.Initialize( image.Attributes.Width / 2, AgGxUnit.UnitPixels, image.Attributes.Height / 2, AgGxUnit.UnitPixels); overlay.Texture = sceneManager.Textures.LoadFromImage(image); sceneManager.Overlays.Add(overlay);
By default, snap shots taken with SaveToFile, SaveToClipboard, and SaveToImage are the same resolution as the 3D window. Sometimes a higher resolution snapshot is desired (e.g. for printing). To take a high resolution snapshot, first set the Resolution property to CameraSnapshotResolutionHigh. Then set HighResolutionWidth and/or HighResolutionDPI before calling a save method. The following example saves a high resolution snapshot to a file.
IAgGxCameraSnapshot snapshot = scene.Camera.Snapshot; snapshot.Resolution = AgGxCameraSnapshotResolution.CameraSnapshotResolutionHigh; snapshot.HighResolutionWidth = 6; // In inches snapshot.HighResolutionDPI = 360; // Dots per inch snapshot.SaveToFile(@"C:\highressnapshot.jpg", AgGxCameraSnapshotFormat.CameraSnapshotFormatJPEG);
Loosely speaking, anti-aliasing makes an image appear smoother. Sometimes it is desirable to anti-alias snapshots that have a lot of vector data, such as polylines and points, to improve visual quality. The following two images demonstrate the different between no anti-aliasing and 4x4 anti-aliasing. Focus on the different between the red outline in each image.
|
|
|
|
No anti-aliasing. |
With 4x4 anti-aliasing, the red outline appears smoother. |
4x4 anti-aliasing means 16 samples were used to derive the color for each pixel. To take anti-aliased snapshots, set the AntiAliasing property to a value other than CameraRecordingAntiAliasingOff as shown below.
IAgGxCameraSnapshot snapshot = scene.Camera.Snapshot; snapshot.AntiAliasing = AgGxCameraRecordingAntiAliasing.CameraRecordingAntiAliasing4x4; snapshot.SaveToClipboard();