BitmapDataExtensionsMakeTransparent(IReadWriteBitmapData, Color32, ParallelConfig) Method
If possible, makes the background of this
bitmapData transparent, using
transparentColor as the background color.
If the
bitmapData does not support transparency, then the pixels that have the same color as
transparentColor will be set
to the
BackColor of
bitmapData.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
public static bool MakeTransparent(
this IReadWriteBitmapData bitmapData,
Color32 transparentColor,
ParallelConfig? parallelConfig
)
<ExtensionAttribute>
Public Shared Function MakeTransparent (
bitmapData As IReadWriteBitmapData,
transparentColor As Color32,
parallelConfig As ParallelConfig
) As Boolean
public:
[ExtensionAttribute]
static bool MakeTransparent(
IReadWriteBitmapData^ bitmapData,
Color32 transparentColor,
ParallelConfig^ parallelConfig
)
[<ExtensionAttribute>]
static member MakeTransparent :
bitmapData : IReadWriteBitmapData *
transparentColor : Color32 *
parallelConfig : ParallelConfig -> bool
- bitmapData IReadWriteBitmapData
- The IReadWriteBitmapData to make transparent.
- transparentColor Color32
- Specifies the color to make transparent.
- parallelConfig ParallelConfig
- The configuration of the operation such as parallelization, cancellation, reporting progress, etc.
When Progress is set in this parameter,
then this library always passes a DrawingOperation instance to the generic methods of
the IAsyncProgress interface.
If , then the degree of parallelization is configured automatically.
Boolean, if the operation completed successfully.
, if the operation has been canceled and the
ThrowIfCanceled property
of the
parallelConfig parameter was
.In Visual Basic and C#, you can call this method as an instance method on any object of type
IReadWriteBitmapData. 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).
This method blocks the caller as it executes synchronously, though the
parallelConfig parameter allows configuring the degree of parallelism,
cancellation and progress reporting. Use the
BeginMakeTransparent(IReadWriteBitmapData, Color32, AsyncConfig)
or
MakeTransparentAsync(IReadWriteBitmapData, Color32, TaskConfig) (in .NET Framework 4.0 and above) methods to perform the operation asynchronously.
Unlike the Bitmap.MakeTransparent(Color) method,
this one preserves the original PixelFormat. If bitmapData does not support transparency and cannot set Palette either,
then every occurrence of the transparentColor will be changed to the BackColor of bitmapData.
To make such bitmaps transparent use the ToTransparent method instead,
which returns a new instance that has a PixelFormat with alpha support.
To auto-detect the background color to be made transparent use the MakeTransparent(IReadWriteBitmapData, ParallelConfig) overload instead.
Please note though that this overload allows a non-completely opaque transparentColor.
If the transparentColor cannot be represented by a Color32 instance,
then use the TransformColors overloads that work with Color64 or ColorF delegate parameters instead.
Please note that unlike the
MakeOpaque method, this one changes exactly one color shade without any tolerance.
For customizations use the
TransformColors overloads instead.