Method CreateBitmapSourceFromImage
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.Framework.dll
CreateBitmapSourceFromImage<TPixel>(IDeviceContext, SizeInt32, IDeviceImage)
Creates an IBitmapSource<TPixel> that renders the given IDeviceImage into
CPU accessible memory.
If the IDeviceContext is using hardware acceleration, rendering will be performed on the GPU
and then copied to CPU memory. This is done on-demand when CopyPixels(void*, int, uint, in RectInt32?)
is called. No caching is used.
public static IBitmapSource<TPixel> CreateBitmapSourceFromImage<TPixel>(this IDeviceContext deviceContext, SizeInt32 pixelSize, IDeviceImage image) where TPixel : unmanaged, INaturalPixelInfo
Parameters
deviceContext
IDeviceContextpixelSize
SizeInt32image
IDeviceImage
Returns
- IBitmapSource<TPixel>
Type Parameters
TPixel
Remarks
For this method overload, the pixel format of the rendering buffer will match the pixel format of the
IBitmapSource. Some effects require higher precision buffers to render correctly (e.g. distortion
effects that use SampleMapRenderer). In that case, use the
CreateBitmapSourceFromImage<TPixel>(IDeviceContext, SizeInt32, IDeviceImage, DevicePixelFormat)
overload and specify something like Prgba128Float.
Note: The pixel format of the IBitmapSource must use premultiplied alpha.
CreateBitmapSourceFromImage<TPixel>(IDeviceContext, SizeInt32, IDeviceImage, DevicePixelFormat)
Creates an IBitmapSource<TPixel> that renders the given IDeviceImage into
CPU accessible memory.
If the IDeviceContext is using hardware acceleration, rendering will be performed on the GPU
and then copied to CPU memory. This is done on-demand when CopyPixels(void*, int, uint, in RectInt32?)
is called. No caching is used.
public static IBitmapSource<TPixel> CreateBitmapSourceFromImage<TPixel>(this IDeviceContext deviceContext, SizeInt32 pixelSize, IDeviceImage image, DevicePixelFormat bufferPixelFormat) where TPixel : unmanaged, INaturalPixelInfo
Parameters
deviceContext
IDeviceContextpixelSize
SizeInt32image
IDeviceImagebufferPixelFormat
DevicePixelFormat
Returns
- IBitmapSource<TPixel>
Type Parameters
TPixel
Remarks
Use this overload to specify a pixel format for the rendering buffer. Some effects require higher precision
buffers to render correctly (e.g. distortion effects that use SampleMapRenderer). In that case
you can specify Prgba128Float for the pixel format. The GPU will be used
to convert from the buffer's pixel format to the IBitmapSource's pixel format.
Note: The pixel format of the IBitmapSource must use premultiplied alpha.