BitmapDataFactoryCreateBitmapDataT(T, Int32, KnownPixelFormat, Palette, FuncPalette, Boolean, Action) Method

Creates an IReadWriteBitmapData instance for a preallocated two dimensional array with the specified parameters.


Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 7.1.0
public static IReadWriteBitmapData CreateBitmapData<T>(
	T[,] buffer,
	int pixelWidth,
	KnownPixelFormat pixelFormat,
	Palette? palette,
	Func<Palette, bool>? trySetPaletteCallback = null,
	Action? disposeCallback = null
where T : struct, new()


buffer  T
A preallocated array to be used as the underlying buffer for the returned IReadWriteBitmapData.
pixelWidth  Int32
The width of the bitmap data to create in pixels.
pixelFormat  KnownPixelFormat
The pixel format in buffer and the bitmap data to create.
palette  Palette
If pixelFormat represents an indexed format, then specifies the desired Palette of the returned IReadWriteBitmapData instance. It determines also the BackColor and AlphaThreshold properties of the result.
trySetPaletteCallback  FuncPalette, Boolean  (Optional)
A delegate to be called when the palette is attempted to be replaced by the TrySetPalette method. If buffer belongs to some custom bitmap implementation, it can be used to update its original palette. This parameter is optional.
Default value: .
disposeCallback  Action  (Optional)
A delegate to be called when the returned IReadWriteBitmapData is disposed or finalized. This parameter is optional.
Default value: .

Type Parameters

The type of the elements in buffer.

Return Value

An IReadWriteBitmapData instance wrapping the specified buffer and using the provided parameters.


ArgumentNullExceptionbuffer is .
ArgumentOutOfRangeExceptionpixelWidth is too large for the specified buffer and pixelFormat
pixelFormat is not one of the valid formats.
ArgumentExceptionbuffer is empty
palette is too large for the specified pixelFormat.

See Also