BitmapDataExtensionsCombine(IReadableBitmapData, IReadWriteBitmapData, FuncColorF, ColorF, ColorF, NullableRectangle, NullablePoint, ParallelConfig) Method
Combines the pixels of the source and target bitmaps using the specified combineFunction, and writes the result into target.
Namespace: KGySoft.Drawing.ImagingAssembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 10.0.0-rc.1
public static bool Combine(
this IReadableBitmapData source,
IReadWriteBitmapData target,
Func<ColorF, ColorF, ColorF> combineFunction,
Rectangle? sourceRectangle = null,
Point? targetLocation = null,
ParallelConfig? parallelConfig = null
)
<ExtensionAttribute>
Public Shared Function Combine (
source As IReadableBitmapData,
target As IReadWriteBitmapData,
combineFunction As Func(Of ColorF, ColorF, ColorF),
Optional sourceRectangle As Rectangle? = Nothing,
Optional targetLocation As Point? = Nothing,
Optional parallelConfig As ParallelConfig = Nothing
) As Boolean
public:
[ExtensionAttribute]
static bool Combine(
IReadableBitmapData^ source,
IReadWriteBitmapData^ target,
Func<ColorF, ColorF, ColorF>^ combineFunction,
Nullable<Rectangle> sourceRectangle = nullptr,
Nullable<Point> targetLocation = nullptr,
ParallelConfig^ parallelConfig = nullptr
)
[<ExtensionAttribute>]
static member Combine :
source : IReadableBitmapData *
target : IReadWriteBitmapData *
combineFunction : Func<ColorF, ColorF, ColorF> *
?sourceRectangle : Nullable<Rectangle> *
?targetLocation : Nullable<Point> *
?parallelConfig : ParallelConfig
(* Defaults:
let _sourceRectangle = defaultArg sourceRectangle null
let _targetLocation = defaultArg targetLocation null
let _parallelConfig = defaultArg parallelConfig null
*)
-> bool
- source IReadableBitmapData
- The source IReadableBitmapData to be combined with the target.
- target IReadWriteBitmapData
- The target IReadWriteBitmapData into which the combined result should be written.
- combineFunction FuncColorF, ColorF, ColorF
- The custom function to be used to combine the colors of the bitmaps. Its first parameter represents a pixel in source,
whereas the second parameter represents the corresponding pixel in target. The function must be thread-safe, as it might be called concurrently.
- sourceRectangle NullableRectangle (Optional)
- A Rectangle that specifies the portion of the source to be combined, or to take the entire source. This parameter is optional.
Default value: . - targetLocation NullablePoint (Optional)
- A Point that specifies the target location, or to write the combined result to the top-left corner of the target. Target size will be always the same as the source size. This parameter is optional.
Default value: . - parallelConfig ParallelConfig (Optional)
- 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
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).
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
BeginCombine
or
CombineAsync (in .NET Framework 4.0 and above) methods to perform the operation asynchronously.
The combined area is automatically clipped if its size or targetLocation makes it impossible to completely fit in the target.
If target can represent a narrower set of colors, then the result will be automatically quantized to the colors of the target.
To use dithering, call the Combine(IReadableBitmapData, IReadWriteBitmapData, FuncColor32, Color32, Color32, NullableRectangle, NullablePoint, IDitherer, ParallelConfig) overload instead, and specify a ditherer.
If you would just take the pixels of source and copy them to target, use the CopyTo methods instead.
Similarly, if you would like to draw the source into target with blending, you can use the DrawInto methods.