BitmapDataFactoryCreateBitmapDataT(Array2DT, Int32, KnownPixelFormat, WorkingColorSpace, Color32, Byte, Action) Method

Creates an IReadWriteBitmapData instance wrapping the specified buffer and using the specified parameters.
See the Remarks section of the CreateBitmapData(Size, KnownPixelFormat, WorkingColorSpace, Color32, Byte) overload for details.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
C#
public static IReadWriteBitmapData CreateBitmapData<T>(
	Array2D<T> buffer,
	int pixelWidth,
	KnownPixelFormat pixelFormat,
	WorkingColorSpace workingColorSpace,
	Color32 backColor,
	byte alphaThreshold,
	Action? disposeCallback = null
)
where T : struct, new()

Parameters

buffer  Array2DT
An Array2D<T> 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.
workingColorSpace  WorkingColorSpace
Specifies the preferred color space that should be used when working with the result bitmap data.
See the Remarks section of the WorkingColorSpace enumeration for more details.
backColor  Color32
For pixel formats without alpha gradient support specifies the BackColor value of the returned IReadWriteBitmapData instance. It does not affect the actual returned bitmap content. See the Remarks section of the CreateBitmapData(Size, KnownPixelFormat, WorkingColorSpace, Color32, Byte) overload for details. The alpha value (Color32.A field) of the specified background color is ignored. This parameter is optional.
Default value: The default value of the Color32 type, which has the same RGB values as Black.
alphaThreshold  Byte
For pixel formats without alpha gradient support specifies the AlphaThreshold value of the returned IReadWriteBitmapData instance. See the Remarks section of the CreateBitmapData(Size, KnownPixelFormat, WorkingColorSpace, Color32, Byte) overload for details. This parameter is optional.
Default value: 128.
disposeCallback  Action  (Optional)
A delegate to be called when the returned IReadWriteBitmapData is disposed or finalized. This parameter is optional.
Default value: .

Type Parameters

T
The type of the elements in buffer.

Return Value

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

Exceptions

ArgumentNullExceptionThe IsNull property of buffer is .
ArgumentOutOfRangeExceptionpixelWidth is too large for the specified buffer and pixelFormat
-or-
pixelFormat is not one of the valid formats
-or-
workingColorSpace is not one of the defined values.
ArgumentExceptionbuffer is empty.

See Also