BitmapDataFactoryCreateBitmapData(IntPtr, Size, Int32, KnownPixelFormat, WorkingColorSpace, Color32, Byte, Action) Method
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.2.0
[SecurityCriticalAttribute]
public static IReadWriteBitmapData CreateBitmapData(
IntPtr buffer,
Size size,
int stride,
KnownPixelFormat pixelFormat,
WorkingColorSpace workingColorSpace,
Color32 backColor = default,
byte alphaThreshold = 128,
Action? disposeCallback = null
)
<SecurityCriticalAttribute>
Public Shared Function CreateBitmapData (
buffer As IntPtr,
size As Size,
stride As Integer,
pixelFormat As KnownPixelFormat,
workingColorSpace As WorkingColorSpace,
Optional backColor As Color32 = Nothing,
Optional alphaThreshold As Byte = 128,
Optional disposeCallback As Action = Nothing
) As IReadWriteBitmapData
public:
[SecurityCriticalAttribute]
static IReadWriteBitmapData^ CreateBitmapData(
IntPtr buffer,
Size size,
int stride,
KnownPixelFormat pixelFormat,
WorkingColorSpace workingColorSpace,
Color32 backColor = Color32(),
unsigned char alphaThreshold = 128,
Action^ disposeCallback = nullptr
)
[<SecurityCriticalAttribute>]
static member CreateBitmapData :
buffer : IntPtr *
size : Size *
stride : int *
pixelFormat : KnownPixelFormat *
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
- buffer IntPtr
- The memory address to be used as the underlying buffer for the returned IReadWriteBitmapData.
Make sure there is enough allocated memory for the specified size, stride and pixelFormat;
otherwise, accessing pixels may corrupt memory or throw an AccessViolationException.
If it points to managed memory make sure it is pinned until the returned bitmap data is disposed.
- 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.
It can be negative for bottom-up layout (ie. when buffer points to the first pixel of the bottom row).
- 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 (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: .
IReadWriteBitmapDataAn
IReadWriteBitmapData instance wrapping the specified
buffer and using the provided parameters.
ArgumentNullException | buffer is IntPtr.Zero. |
ArgumentOutOfRangeException | size has a zero or negative width or height
-or-
pixelFormat is not one of the valid formats
-or-
The absolute value of stride is too small for the specified width and pixelFormat -or-
workingColorSpace is not one of the defined values. |