BitmapExtensionsGetReadableBitmapData(Bitmap, WorkingColorSpace, Color, Byte) Method

Gets an IReadableBitmapData instance, which provides fast read-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: 9.0.0
C#
public static IReadableBitmapData GetReadableBitmapData(
	this Bitmap bitmap,
	WorkingColorSpace workingColorSpace,
	Color backColor = default,
	byte alphaThreshold = 128
)

Parameters

bitmap  Bitmap
A Bitmap instance, whose data is about to be accessed.
workingColorSpace  WorkingColorSpace
Specifies the preferred color space that should be used when working with the result bitmap data. Determines the behavior of some operations such as resizing or looking up for nearest colors if bitmap has an indexed pixel format.
See the Remarks section of the WorkingColorSpace enumeration for more details.
backColor  Color  (Optional)
Just like workingColorSpace, for an IReadableBitmapData instance the backColor is relevant only for indexed bitmaps when GetNearestColorIndex and GetNearestColor methods are called with an alpha color on the Palette property. Queried colors with alpha, which are considered opaque will be blended with this color before performing a lookup. 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)
Similarly to backColor, for an IReadableBitmapData instance the alphaThreshold is relevant only for indexed bitmaps when GetNearestColorIndex and GetNearestColor methods are called with an alpha color on the Palette property. In such case determines the lowest alpha value of a color, which should not be considered as transparent. If 0, then a color lookup will never return a transparent color. This parameter is optional.
Default value: 128.

Return Value

IReadableBitmapData
An IReadableBitmapData instance, which provides fast read-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