BitmapExtensionsGetWritableBitmapData(Bitmap, Color, Byte) Method

Gets an IWritableBitmapData instance, which provides fast write-only access to the actual data of the specified bitmap. The bitmap can have any PixelFormat.
See the Remarks section of the GetReadWriteBitmapData method for details and examples.

Definition

Namespace: KGySoft.Drawing
Assembly: KGySoft.Drawing (in KGySoft.Drawing.dll) Version: 8.1.0
C#
public static IWritableBitmapData GetWritableBitmapData(
	this Bitmap bitmap,
	Color backColor = default,
	byte alphaThreshold = 128
)

Parameters

bitmap  Bitmap
A Bitmap instance, whose data is about to be accessed.
backColor  Color  (Optional)
When setting pixels of indexed bitmaps and bitmaps without alpha support or with single bit alpha, then specifies the color of the background. Color values with alpha, which are considered opaque will be blended with this color before setting the pixel in the result bitmap data. The alpha value (Color.A property) of the specified background color is ignored. This parameter is optional.
Default value: Color.Empty, which has the same RGB values as Black.
alphaThreshold  Byte  (Optional)
When setting pixels of bitmaps with single bit alpha or with a palette that has a transparent color, then specifies a threshold value for the Color.A property, under which the color is considered transparent. If 0, then the pixels to be set will never be transparent. This parameter is optional.
Default value: 128.

Return Value

IWritableBitmapData
An IWritableBitmapData instance, which provides fast write-only access to the actual data of the specified bitmap.

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type Bitmap. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

See Also