BitmapDataFactoryCreateBitmapData(IntPtr, Size, Int32, CustomIndexedBitmapDataConfig) Method

Creates an IReadWriteBitmapData instance with a custom non-indexed pixel format wrapping an unmanaged buffer and using the specified parameters.
See the Remarks section of the CreateBitmapDataT(T, Size, Int32, CustomIndexedBitmapDataConfig) overload for details.


Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 8.0.0
public static IReadWriteBitmapData CreateBitmapData(
	IntPtr buffer,
	Size size,
	int stride,
	CustomIndexedBitmapDataConfig customBitmapDataConfig


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).
customBitmapDataConfig  CustomIndexedBitmapDataConfig
The configuration for the custom pixel format. Either the getter or the setter delegate must be specified. If you can ensure that the delegates don't capture buffer or its owner object to make sure you set the BackBufferIndependentPixelAccess property to .

Return Value

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


ArgumentNullExceptionbuffer is IntPtr.Zero
customBitmapDataConfig is .
ArgumentOutOfRangeExceptionsize has a zero or negative width or height
The absolute value of stride is too small for the specified width and PixelFormat.
ArgumentExceptionPalette in customBitmapDataConfig is too large for the specified PixelFormat
PixelFormat in customBitmapDataConfig is not indexed or its BitsPerPixel is not between 1 and 16.
-or- Neither the getter nor the setter delegate is specified in customBitmapDataConfig.

See Also