BitmapDataFactoryCreateBitmapDataT(T, Size, Int32, PixelFormatInfo, FuncICustomBitmapDataRowT, Int32, Color32, ActionICustomBitmapDataRowT, Int32, Color32, WorkingColorSpace, Color32, Byte, Action) Method
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
public static IReadWriteBitmapData CreateBitmapData<T>(
T[] buffer,
Size size,
int stride,
PixelFormatInfo pixelFormatInfo,
Func<ICustomBitmapDataRow<T>, int, Color32>? rowGetColor,
Action<ICustomBitmapDataRow<T>, int, Color32>? rowSetColor,
WorkingColorSpace workingColorSpace,
Color32 backColor = default,
byte alphaThreshold = 128,
Action? disposeCallback = null
)
where T : struct, new()
Public Shared Function CreateBitmapData(Of T As {Structure, New}) (
buffer As T(),
size As Size,
stride As Integer,
pixelFormatInfo As PixelFormatInfo,
rowGetColor As Func(Of ICustomBitmapDataRow(Of T), Integer, Color32),
rowSetColor As Action(Of ICustomBitmapDataRow(Of T), Integer, Color32),
workingColorSpace As WorkingColorSpace,
Optional backColor As Color32 = Nothing,
Optional alphaThreshold As Byte = 128,
Optional disposeCallback As Action = Nothing
) As IReadWriteBitmapData
public:
generic<typename T>
where T : value class, gcnew()
static IReadWriteBitmapData^ CreateBitmapData(
array<T>^ buffer,
Size size,
int stride,
PixelFormatInfo pixelFormatInfo,
Func<ICustomBitmapDataRow<T>^, int, Color32>^ rowGetColor,
Action<ICustomBitmapDataRow<T>^, int, Color32>^ rowSetColor,
WorkingColorSpace workingColorSpace,
Color32 backColor = Color32(),
unsigned char alphaThreshold = 128,
Action^ disposeCallback = nullptr
)
static member CreateBitmapData :
buffer : 'T[] *
size : Size *
stride : int *
pixelFormatInfo : PixelFormatInfo *
rowGetColor : Func<ICustomBitmapDataRow<'T>, int, Color32> *
rowSetColor : Action<ICustomBitmapDataRow<'T>, int, Color32> *
workingColorSpace : WorkingColorSpace *
?backColor : Color32 *
?alphaThreshold : byte *
?disposeCallback : Action
(* Defaults:
let _backColor = defaultArg backColor new Color32()
let _alphaThreshold = defaultArg alphaThreshold 128
let _disposeCallback = defaultArg disposeCallback null
*)
-> IReadWriteBitmapData when 'T : struct, new()
- buffer T
- A preallocated array to be used as the underlying buffer for the returned IReadWriteBitmapData.
It can be larger than it is required for the specified parameters.
If the actual image data starts at some offset use the CreateBitmapDataT(ArraySectionT, Size, Int32, PixelFormatInfo, FuncICustomBitmapDataRowT, Int32, Color32, ActionICustomBitmapDataRowT, Int32, Color32, WorkingColorSpace, Color32, Byte, Action) overload instead.
- size Size
- The size of the bitmap data to create in pixels.
- stride Int32
- The size of a row in bytes. It allows to have some padding at the end of each row.
- pixelFormatInfo PixelFormatInfo
- A PixelFormatInfo instance that describes the pixel format.
- rowGetColor FuncICustomBitmapDataRowT, Int32, Color32
- A delegate that can get the 32-bit color of a pixel in a row of the bitmap data.
If pixelFormatInfo represents a wider format it is recommended to use the CreateBitmapDataT(T, Size, Int32, CustomBitmapDataConfig) overload instead.
If , then the returned instance will be write-only (can be cast to IWritableBitmapData).
- rowSetColor ActionICustomBitmapDataRowT, Int32, Color32
- A delegate that can set the color of a pixel from a Color32 value in a row of the bitmap data.
If pixelFormatInfo represents a wider format it is recommended to use the CreateBitmapDataT(T, Size, Int32, CustomBitmapDataConfig) overload instead.
If , then the returned instance will be read-only (can be cast to IReadableBitmapData).
- 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 (Optional)
- 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 (Optional)
- 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: .
- T
- The type of the elements in buffer.
IReadWriteBitmapDataAn
IReadWriteBitmapData instance wrapping the specified
buffer and using the provided parameters.
ArgumentNullException | buffer is .
-or-
Both rowGetColor and rowSetColor are . |
ArgumentOutOfRangeException | size has a zero or negative width or height
-or-
stride is too small for the specified width and pixelFormatInfo.
|
ArgumentException | buffer is too small for the specified size, pixelFormatInfo and stride -or-
stride is not a multiple of the size of T -or-
pixelFormatInfo is indexed or its BitsPerPixel is 0. |