Method CreateBitmap
- Namespace
- PaintDotNet.Direct2D1
- Assembly
- PaintDotNet.Windows.dll
CreateBitmap(SizeInt32, void*, int, in BitmapProperties)
Creates a bitmap that can be used as a target surface, for reading back to the CPU, or as a source for the DrawBitmap(IDeviceBitmap, in RectFloat?, float, InterpolationMode, in RectFloat?, in Matrix4x4Float?) and IBitmapBrush APIs. In addition, color context information can be passed to the bitmap.
IDeviceBitmap CreateBitmap(SizeInt32 size, void* pSrcData, int stride, in BitmapProperties bitmapProperties)
Parameters
size
SizeInt32The pixel size of the bitmap to be created.
pSrcData
void*A pointer to the initial data that will be loaded into the bitmap. May be null.
stride
intThe stride of the source data, if specified.
bitmapProperties
BitmapPropertiesThe properties of the bitmap to be created.
Returns
- IDeviceBitmap
The new bitmap object.
Remarks
The new bitmap can be used as a target for SetTarget(IDeviceImage?) if it is created with Target.
CreateBitmap(IBitmapSource, in BitmapProperties?)
Creates a Direct2D bitmap by copying an IBitmapSource.
IDeviceBitmap CreateBitmap(IBitmapSource bitmapSource, in BitmapProperties? bitmapProperties = null)
Parameters
bitmapSource
IBitmapSourceThe bitmap source to copy from.
bitmapProperties
BitmapProperties?A bitmap properties structure that specifies bitmap creation options. The pixel format must match the pixel format of the bitmap source, or the method will fails. To prevent a mismatch, you can pass null. If both dpiX and dpiY are 0, the default DPI of 96 will be used. The DPI information embedded in the bitmap source is ignored.
Returns
- IDeviceBitmap
The new bitmap object.
Remarks
The bitmapProperties
parameter is optional. When it is not specified, the created bitmap inherits the
pixel format and alpha mode from bitmapSource
. For a list of supported pixel formats and alpha modes,
see Supported Pixel Formats and Alpha Modes.
When the bitmapProperties parameter is specified, the value in DxgiFormat must either be Unknown
or must match the pixel format of the bitmapSource
.
When the AlphaMode is set to Unknown, the newly created bitmap inherits the alpha
mode from bitmapSource
. When the AlphaMode is set to Premultiplied,
Straight, or Ignore, this forces the newly created bitmap to use the specified
alpha mode.
Before Direct2D can load from a bitmap source, it must be converted to a supported pixel format and alpha mode. For a list of
supported pixel formats and alpha modes, see Supported Pixel Formats and Alpha Modes.