Click or drag to resize
AB4D logo

BaseCameraRenderToBitmap Method (Int32, Int32, Int32, Brush, Int32)

Renders TargetViewport3D to bitmap. It is possible to specify custom bitmap width and height (when customWidth and customHeight are bigger than 0). When antialiasingLevel is bigger than 1, the bitmap is rendered into bigger image and than scaled down to create an antialiasing effect.

Namespace:  Ab3d.Cameras
Assembly:  Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 10.1.8147.1045
Syntax
C#
public BitmapSource RenderToBitmap(
	int customWidth,
	int customHeight,
	int antialiasingLevel = 0,
	Brush backgroundBrush = null,
	int dpi = 96
)

Parameters

customWidth
Type: SystemInt32
when bigger than 0 it specifies the target bitmap width; when zero the width of objectToRender will be used
customHeight
Type: SystemInt32
when bigger than 0 it specifies the target bitmap height; when zero the height of objectToRender will be used
antialiasingLevel (Optional)
Type: SystemInt32
when bigger than 1, the bitmap will be rendered into bigger image and than scaled down to create an antialiasing effect. The antialiasingLevel defines the scale factor of the intermediate bitmap. Max value is 8.
backgroundBrush (Optional)
Type: System.Windows.MediaBrush
brush used for background or null to have no background. Default value is null.
dpi (Optional)
Type: SystemInt32
DPI settinig for the rendered bitmap. Default value is 96

Return Value

Type: BitmapSource
BitmapSource
Remarks

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.

See Also