BitmapDataExtensionsDrawInto(IReadableBitmapData, IReadWriteBitmapData, Rectangle, IQuantizer, IDitherer, ScalingMode, ParallelConfig) Method

Draws the source IReadableBitmapData into the target IReadWriteBitmapData using scaling and blending. This method works between any pair of source and target KnownPixelFormats and supports quantizing and dithering. To copy a bitmap data into another one without blending use the CopyTo methods, or to use custom a function to specify how the source and target pixels should be combined, use the Combine methods instead.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
C#
public static bool DrawInto(
	this IReadableBitmapData source,
	IReadWriteBitmapData target,
	Rectangle targetRectangle,
	IQuantizer? quantizer,
	IDitherer? ditherer,
	ScalingMode scalingMode,
	ParallelConfig? parallelConfig
)

Parameters

source  IReadableBitmapData
The source IReadableBitmapData to be drawn into the target.
target  IReadWriteBitmapData
The target IReadWriteBitmapData into which source should be drawn.
targetRectangle  Rectangle
A Rectangle that specifies the location and size of the drawn source.
quantizer  IQuantizer
An IQuantizer instance to be used for the drawing. If not specified, then the drawing operation might automatically pick a quantizer based on target PixelFormat. This parameter is optional.
Default value: .
ditherer  IDitherer
The ditherer to be used for the drawing. Might be ignored if quantizer is not specified and target PixelFormat format has at least 24 bits-per-pixel size. This parameter is optional.
Default value: .
scalingMode  ScalingMode
Specifies the scaling mode if the bitmap data to be drawn needs to be resized. This parameter is optional.
Default value: Auto.
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.

Return Value

Boolean
, if the operation completed successfully.
, if the operation has been canceled and the ThrowIfCanceled property of the parallelConfig parameter was .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type IReadableBitmapData. 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).

Remarks

  Note

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 BeginDrawInto(IReadableBitmapData, IReadWriteBitmapData, Rectangle, Rectangle, IQuantizer, IDitherer, ScalingMode, AsyncConfig) or DrawIntoAsync(IReadableBitmapData, IReadWriteBitmapData, Rectangle, Rectangle, IQuantizer, IDitherer, ScalingMode, TaskConfig) (in .NET Framework 4.0 and above) methods to perform the operation asynchronously.

The method has the best performance if source and targetRectangle have the same size, or when scalingMode is NoScaling.

The image to be drawn is automatically clipped if targetRectangle exceeds bounds, or scalingMode is NoScaling and source and targetRectangle have different sizes.

target must be an IReadWriteBitmapData because it must be readable if blending is necessary. For write-only IWritableBitmapData instances you can use the CopyTo methods (without scaling).

If target can represent a narrower set of colors, then the result will be automatically quantized to the colors of the target, even if there is no quantizer specified. To use dithering a ditherer must be explicitly specified though.

If quantizer is specified, but it uses more/different colors than target can represent, then the result will eventually be quantized to target, though the result may have a poorer quality than expected.

Exceptions

ArgumentNullExceptionsource or target is .
ArgumentOutOfRangeExceptionscalingMode has an unsupported value.

See Also