BitmapDataExtensionsQuantize(IReadWriteBitmapData, IQuantizer, ParallelConfig) Method
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
public static bool Quantize(
this IReadWriteBitmapData bitmapData,
IQuantizer quantizer,
ParallelConfig? parallelConfig
)
<ExtensionAttribute>
Public Shared Function Quantize (
bitmapData As IReadWriteBitmapData,
quantizer As IQuantizer,
parallelConfig As ParallelConfig
) As Boolean
public:
[ExtensionAttribute]
static bool Quantize(
IReadWriteBitmapData^ bitmapData,
IQuantizer^ quantizer,
ParallelConfig^ parallelConfig
)
[<ExtensionAttribute>]
static member Quantize :
bitmapData : IReadWriteBitmapData *
quantizer : IQuantizer *
parallelConfig : ParallelConfig -> bool
- bitmapData IReadWriteBitmapData
- An IReadWriteBitmapData instance to be quantized.
- quantizer IQuantizer
- An IQuantizer implementation to be used for quantizing the specified bitmapData.
- 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
BeginQuantize or
QuantizeAsync
(in .NET Framework 4.0 and above) methods to perform the operation asynchronously.
This method quantizes the specified bitmapData in place (its original content will be overwritten). To return a new instance
use the Clone extension method instead.
If the KnownPixelFormat or the palette of bitmapData is not compatible with the colors of the specified quantizer, then
the result may not be correct.
If bitmapData has already the same set of colors that the specified quantizer, then it can happen
that calling this method does not change the bitmapData at all.
- To use predefined colors or custom quantization functions use the static methods of the PredefinedColorsQuantizer class.
See the Remarks section of its members for details and examples. - To use an optimized palette of a specified number of colors adjusted for bitmapData see the OptimizedPaletteQuantizer class.