|
DXViewRenderToBitmap(DXViewRenderedBitmapReadyDelegate, Int32, Int32, Int32, Int32, Double, Double, Boolean) Method |
RenderToBitmap renders the 3D scene and then calls the specified renderedBitmapReadyCallback
where user can copy rendered bitmap from the mapped GPU mapped memory to main memory.
See remarks for a code sample for a OnRenderedBitmapReady method.
See also other overrides of RenderToBitmap method:
RenderToBitmap,
RenderToBitmap(Int32, Int32, Int32, Int32, Boolean),
RenderToBitmap(Int32, Int32, Int32, Double, Double),
RenderToBitmap(Int32, Int32, Int32, Int32, Double, Double, Boolean).
Namespace: Ab3d.DirectX.ControlsAssembly: Ab3d.DXEngine.Wpf (in Ab3d.DXEngine.Wpf.dll) Version: 7.1.9105.2048
Syntax public void RenderToBitmap(
DXViewRenderedBitmapReadyDelegate renderedBitmapReadyCallback,
int width = -1,
int height = -1,
int preferedMultisampling = -1,
int supersamplingCount = 1,
double dpiX = 96,
double dpiY = 96,
bool convertToNonPreMultipledAlpha = false
)
Parameters
- renderedBitmapReadyCallback DXViewRenderedBitmapReadyDelegate
- RenderedBitmapReadyDelegate delegate that is called when the rendered bitmap is ready to be copied from GPU mapped memory to main memory
- width Int32 (Optional)
- width of the rendered bitmap (when -1; by default) then the width of the current DXScene is used
- height Int32 (Optional)
- height of the rendered bitmap (when -1; by default) then the height of the current DXScene is used
- preferedMultisampling Int32 (Optional)
- multisampling count that is used to render the image (used if possible). When -1 is specified (by default), then the current multisampling count from DXScene is used.
- supersamplingCount Int32 (Optional)
- super-sampling count (possible values: 1 no super-sampling, 4, 16, 64)
- dpiX Double (Optional)
- The horizontal DPI of the bitmap.
- dpiY Double (Optional)
- The vertical DPI of the bitmap.
- convertToNonPreMultipledAlpha Boolean (Optional)
- when true (false by default) then the image in converted into non-premultiplied alpha (this can be used when saving to png file that does not support pre-multiplied alpha)
Remarks Example The following code show a possible code for OnRenderedBitmapReady method that is used for the renderedBitmapReadyCallback delegate
private WriteableBitmap _writeableBitmap;
private void OnRenderedBitmapReady(int width, int height, DataBox data)
{
if (_writeableBitmap != null &&
(_writeableBitmap.PixelWidth != width || _writeableBitmap.PixelHeight != height))
{
_writeableBitmap = null;
}
if (_writeableBitmap == null)
_writeableBitmap = new WriteableBitmap(width, height, 96, 96, PixelFormats.Pbgra32, null);
_writeableBitmap.Lock();
var viewportRect = new Int32Rect(0, 0, width, height);
_writeableBitmap.WritePixels(viewportRect, data.DataPointer, data.SlicePitch, data.RowPitch);
_writeableBitmap.AddDirtyRect(viewportRect);
_writeableBitmap.Unlock();
}
See Also