예제 #1
0
            /// <inheritdoc />
            public override void Blend(MemoryAllocator memoryManager, Span <TPixel> destination, Span <TPixel> background, Span <TPixel> source, Span <float> amount)
            {
                Guard.MustBeGreaterThanOrEqualTo(background.Length, destination.Length, nameof(background.Length));
                Guard.MustBeGreaterThanOrEqualTo(source.Length, destination.Length, nameof(source.Length));
                Guard.MustBeGreaterThanOrEqualTo(amount.Length, destination.Length, nameof(amount.Length));

                using (IMemoryOwner <Vector4> buffer = memoryManager.Allocate <Vector4>(destination.Length * 3))
                {
                    Span <Vector4> destinationSpan = buffer.Slice(0, destination.Length);
                    Span <Vector4> backgroundSpan  = buffer.Slice(destination.Length, destination.Length);
                    Span <Vector4> sourceSpan      = buffer.Slice(destination.Length * 2, destination.Length);

                    PixelOperations <TPixel> .Instance.ToVector4(background, backgroundSpan, destination.Length);

                    PixelOperations <TPixel> .Instance.ToVector4(source, sourceSpan, destination.Length);

                    for (int i = 0; i < destination.Length; i++)
                    {
                        destinationSpan[i] = PorterDuffFunctions.Xor(backgroundSpan[i], sourceSpan[i], amount[i]);
                    }

                    PixelOperations <TPixel> .Instance.PackFromVector4(destinationSpan, destination, destination.Length);
                }
            }
예제 #2
0
 /// <inheritdoc />
 public override TPixel Blend(TPixel background, TPixel source, float amount)
 {
     return(PorterDuffFunctions.Xor(background, source, amount));
 }