public void Render(ISurface <TPixel> dst, PointInt32 renderOffset)
        {
            dst.Clear <TPixel>();
            SizeInt32  size     = dst.Size <TPixel>();
            RectInt32  num2     = new RectInt32(renderOffset, size);
            PointInt32 location = new PointInt32(renderOffset.X - this.offset.X, renderOffset.Y - this.offset.Y);
            RectInt32  a        = new RectInt32(location, size);
            RectInt32  num5     = RectInt32.Intersect(a, this.source.Bounds <TPixel>());

            if (num5.HasPositiveArea)
            {
                PointInt32 num6   = new PointInt32(num5.X - a.X, num5.Y - a.Y);
                RectInt32  bounds = new RectInt32(num6, num5.Size);
                if (bounds.Location.IsZero && (bounds.Size == size))
                {
                    this.source.Render(dst, location);
                }
                else
                {
                    using (ISurface <TPixel> surface = dst.CreateWindow <TPixel>(bounds))
                    {
                        this.source.Render(surface, num5.Location);
                    }
                }
            }
        }
        public unsafe TransformedNearestNeighborContentRenderer(SizeInt32 size, ISurface <ColorBgra> content, Matrix3x2Double matrix) : base(size.Width, size.Height, true)
        {
            Validate.Begin().IsPositive(size.Width, "size.Width").IsPositive(size.Height, "size.Height").IsTrue(matrix.HasInverse, "matrix.HasInverse").Check();
            this.content       = content;
            this.contentWidth  = this.content.Width;
            this.contentHeight = this.content.Height;
            this.contentScan0  = (ColorBgra *)this.content.Scan0;
            this.contentStride = this.content.Stride;
            this.matrix        = matrix;
            this.invMatrix     = this.matrix.Inverse;
            PointDouble pt    = new PointDouble(0.5, 0.5);
            PointDouble num2  = new PointDouble(0.5, 1.5);
            PointDouble num3  = new PointDouble(1.5, 0.5);
            PointDouble num4  = this.invMatrix.Transform(pt);
            PointDouble num5  = this.invMatrix.Transform(num2);
            PointDouble num6  = this.invMatrix.Transform(num3);
            PointDouble num7  = new PointDouble(num4.X, num4.Y);
            PointDouble num8  = new PointDouble(num5.X, num5.Y);
            PointDouble num9  = new PointDouble(num6.X, num6.Y);
            double      num10 = num9.X - num7.X;
            double      num11 = num9.Y - num7.Y;
            double      num12 = num8.X - num7.X;
            double      num13 = num8.Y - num7.Y;

            this.srcOffsetOriginXFp = DoubleUtil.ClampToInt64(num7.X * 16777216.0);
            this.srcOffsetOriginYFp = DoubleUtil.ClampToInt64(num7.Y * 16777216.0);
            this.srcOffsetDxDxFp    = DoubleUtil.ClampToInt64(num10 * 16777216.0);
            this.srcOffsetDyDxFp    = DoubleUtil.ClampToInt64(num11 * 16777216.0);
            this.srcOffsetDxDyFp    = DoubleUtil.ClampToInt64(num12 * 16777216.0);
            this.srcOffsetDyDyFp    = DoubleUtil.ClampToInt64(num13 * 16777216.0);
        }
Beispiel #3
0
        public void Render(ISurface <ColorBgra> dst, PointInt32 renderOffset)
        {
            SizeInt32 size = dst.Size <ColorBgra>();

            this.source.Render(dst, renderOffset);
            using (ISurface <ColorAlpha8> surface = this.alpha.UseTileOrToSurface(new RectInt32(renderOffset, size)))
            {
                dst.MultiplyAlphaChannel(surface);
            }
        }
Beispiel #4
0
        private void RenderMask(ISurface <ColorAlpha8> dstMask, PointInt32 renderOffset)
        {
            int       width     = dstMask.Width;
            int       height    = dstMask.Height;
            bool      flag      = false;
            SizeInt32 size      = new SizeInt32(width, height);
            RectInt32 rectangle = new RectInt32(renderOffset, size);

            if (!flag && this.matrix.HasInverse)
            {
                Matrix3x2Double inverse           = this.matrix.Inverse;
                PointDouble     pt                = inverse.Transform(rectangle.TopLeft);
                PointDouble     num7              = inverse.Transform(rectangle.TopRight);
                PointDouble     num8              = inverse.Transform(rectangle.BottomLeft);
                PointDouble     num9              = inverse.Transform(rectangle.BottomRight);
                RectDouble      srcCoverageBounds = this.srcCoverageBounds;
                if ((srcCoverageBounds.Contains(pt) && srcCoverageBounds.Contains(num7)) && (srcCoverageBounds.Contains(num8) && srcCoverageBounds.Contains(num9)))
                {
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                }
            }
            if (!flag)
            {
                GeometryRelation relation;
                IDirect2DFactory perThread = Direct2DFactory.PerThread;
                using (IRectangleGeometry geometry = perThread.CreateRectangleGeometry(rectangle))
                {
                    base.ThrowIfCancellationRequested();
                    using (IRectangleGeometry geometry2 = perThread.CreateRectangleGeometry(this.srcCoverageBounds))
                    {
                        base.ThrowIfCancellationRequested();
                        relation = geometry.CompareWithGeometry(geometry2, new Matrix3x2Float?((Matrix3x2Float)this.matrix), null);
                        base.ThrowIfCancellationRequested();
                    }
                }
                switch (relation)
                {
                case GeometryRelation.IsContained:
                    dstMask.Clear(ColorAlpha8.Opaque);
                    flag = true;
                    break;

                case GeometryRelation.Disjoint:
                    dstMask.Clear(ColorAlpha8.Transparent);
                    flag = true;
                    break;
                }
            }
            if (!flag)
            {
                using (IDrawingContext context = DrawingContext.FromSurface(dstMask, FactorySource.PerThread))
                {
                    base.ThrowIfCancellationRequested();
                    context.Clear(null);
                    context.AntialiasMode = AntialiasMode.PerPrimitive;
                    using (context.UseTranslateTransform((float)-renderOffset.X, (float)-renderOffset.Y, MatrixMultiplyOrder.Prepend))
                    {
                        using (context.UseTransformMultiply((Matrix3x2Float)this.matrix, MatrixMultiplyOrder.Prepend))
                        {
                            context.FillRectangle(this.srcCoverageBounds, whiteBrush);
                        }
                    }
                }
            }
        }
 internal MaskFromScansRenderer(TList sortedScans, RectInt32 bounds)
 {
     this.origin = bounds.Location;
     this.size   = bounds.Size;
     this.scans  = sortedScans;
 }
Beispiel #6
0
 public static IRenderer <ColorBgra> CreateRenderer(this PdnBrush brush, SizeInt32 size) =>
 brush.CreateRenderer(size.Width, size.Height);