|
BitmapRenderingRenderToBitmap(FrameworkElement, Int32, Int32, Boolean, Int32, Brush, Int32, RenderTargetBitmap) Method |
Renders FrameworkElement specified with objectToRender 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.UtilitiesAssembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 11.1.8864.1045
Syntax public static BitmapSource RenderToBitmap(
FrameworkElement objectToRender,
int customWidth,
int customHeight,
bool scaleToFill = true,
int antialiasingLevel = 0,
Brush backgroundBrush = null,
int dpi = 96,
RenderTargetBitmap renderTargetBitmapToReuse = null
)
Parameters
- objectToRender FrameworkElement
- FrameworkElement to render
- customWidth Int32
- when bigger than 0 it specifies the target bitmap width; when zero the width of objectToRender will be used
- customHeight Int32
- when bigger than 0 it specifies the target bitmap height; when zero the height of objectToRender will be used
- scaleToFill Boolean (Optional)
- when true the object will be scaled to fill the target bitmap (when source and target aspect ratio is not the same)
- antialiasingLevel Int32 (Optional)
- 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. When antialiasingLevel value is bigger then 1, then a TransformedBitmap object type is returned, otherwise a RenderTargetBitmap object type is returned.
- backgroundBrush Brush (Optional)
- brush used for background or null to have no background. Default value is null.
- dpi Int32 (Optional)
- DPI setting for the rendered bitmap. Default value is 96
- renderTargetBitmapToReuse RenderTargetBitmap (Optional)
- when not null and when its size is the same as the size defined by the customWidth and customHeight, then the renderTargetBitmapToReuse is cleared and used again to improve memory usage.
Return Value
BitmapSourceBitmapSource
See Also