Base |
public BitmapSource RenderToBitmap( int customWidth, int customHeight, int antialiasingLevel = 0, Brush backgroundBrush = null, int dpi = 96 )
RenderToBitmap method renders TargetViewport3D to bitmap.
It is possible to specify custom bitmap width and height (when customWidth and customHeight are bigger than 0).
It is also possible to specify only one width or only height. In this case the other size component is calculated in such a way that the aspect ratio is preserved.
When the aspect ratio (= width / height) of the Viewport3D is not the same as the aspect ratio of the target bitmap, the Viewport3D is uniformly scaled to fill the target bitmap.
When antialiasingLevel is bigger than 1, the bitmap is rendered into bigger image and than scaled down to create an antialiasing effect.
When no custom size or antialiasing is required, you can also use the RenderToBitmap(Brush, Int32) method.
When TargetViewport3D is rendered with DXEngine, then this method call DXView.RenderToBitmap method to get the actually visible scene.
When WPF 3D rendering is used, then this method internally calls RenderToBitmap(FrameworkElement, Int32, Int32, Boolean, Int32, Brush, Int32, RenderTargetBitmap) method. You can use it to render any other WPF FrameworkElement (instead of Viewport3D) to bitmap. You can also use it to set the scaleToFill to false.