Exemplo n.º 1
0
        /// <inheritdoc/>
        protected override void OnFrameApply(ImageFrame <TPixel> source, Rectangle sourceRectangle, Configuration configuration)
        {
            var interest = Rectangle.Intersect(sourceRectangle, source.Bounds());
            int startX   = interest.X;

            ColorMatrix matrix = this.definition.Matrix;

            ParallelHelper.IterateRowsWithTempBuffer <Vector4>(
                interest,
                configuration,
                (rows, vectorBuffer) =>
            {
                for (int y = rows.Min; y < rows.Max; y++)
                {
                    Span <Vector4> vectorSpan = vectorBuffer.Span;
                    int length            = vectorSpan.Length;
                    Span <TPixel> rowSpan = source.GetPixelRowSpan(y).Slice(startX, length);
                    PixelOperations <TPixel> .Instance.ToVector4(configuration, rowSpan, vectorSpan);

                    Vector4Utils.Transform(vectorSpan, ref matrix);

                    PixelOperations <TPixel> .Instance.FromVector4Destructive(configuration, vectorSpan, rowSpan);
                }
            });
        }
Exemplo n.º 2
0
            public void Invoke(int y, Span <Vector4> span)
            {
                Span <TPixel> rowSpan = this.source.GetPixelRowSpan(y).Slice(this.startX, span.Length);

                PixelOperations <TPixel> .Instance.ToVector4(this.configuration, rowSpan, span);

                Vector4Utils.Transform(span, ref Unsafe.AsRef(this.matrix));

                PixelOperations <TPixel> .Instance.FromVector4Destructive(this.configuration, span, rowSpan);
            }