Exemplo n.º 1
0
        public void Render(IDrawingContextImpl context)
        {
            var finalRenderSurface = context.CreateLayer(_destRect.Size);

            if (finalRenderSurface is null)
            {
                context.Clear(Colors.Aqua);
                return;
            }

            using (var renderSurfaceCtx = finalRenderSurface.CreateDrawingContext(null))
            {
                using (_lottieCanvas.CreateSession(_destRect.Size, finalRenderSurface,
                                                   new DrawingContext(renderSurfaceCtx)))
                {
                    _compositionLayer.Draw(_lottieCanvas, _matrix, 255);
                }
            }

            context.DrawBitmap(RefCountable.Create(finalRenderSurface),
                               1,
                               new Rect(new Point(), finalRenderSurface.PixelSize.ToSize(1)), _destRect);

            finalRenderSurface.Dispose();
        }
Exemplo n.º 2
0
        public void RecreateBitmap(IDrawingContextImpl drawingContext, Size size, double scaling)
        {
            if (Size != size || Scaling != scaling)
            {
                var resized = RefCountable.Create(drawingContext.CreateLayer(size));

                using (var context = resized.Item.CreateDrawingContext(null))
                {
                    Bitmap.Dispose();
                    context.Clear(default);
Exemplo n.º 3
0
 public RenderLayer(
     IDrawingContextImpl drawingContext,
     Size size,
     double scaling,
     IVisual layerRoot)
 {
     Bitmap    = RefCountable.Create(drawingContext.CreateLayer(size));
     Size      = size;
     Scaling   = scaling;
     LayerRoot = layerRoot;
     IsEmpty   = true;
 }
Exemplo n.º 4
0
 public RenderLayer(
     IDrawingContextImpl drawingContext,
     Size size,
     double scaling,
     IVisual layerRoot)
 {
     _drawingContext = drawingContext;
     Bitmap          = drawingContext.CreateLayer(size);
     Size            = size;
     Scaling         = scaling;
     LayerRoot       = layerRoot;
 }
Exemplo n.º 5
0
        public void ResizeBitmap(Size size, double scaling)
        {
            if (Size != size || Scaling != scaling)
            {
                var resized = RefCountable.Create(_drawingContext.CreateLayer(size));

                using (var context = resized.Item.CreateDrawingContext(null))
                {
                    context.Clear(Colors.Transparent);
                    context.DrawImage(Bitmap, 1, new Rect(Size), new Rect(Size));
                    Bitmap.Dispose();
                    Bitmap = resized;
                    Size   = size;
                }
            }
        }
Exemplo n.º 6
0
        private IRef <IRenderTargetBitmapImpl> GetOverlay(
            IDrawingContextImpl parentContext,
            Size size,
            double scaling)
        {
            var pixelSize = size * scaling;

            if (_overlay == null ||
                _overlay.Item.PixelWidth != pixelSize.Width ||
                _overlay.Item.PixelHeight != pixelSize.Height)
            {
                _overlay?.Dispose();
                _overlay = RefCountable.Create(parentContext.CreateLayer(size));
            }

            return(_overlay);
        }
Exemplo n.º 7
0
        public void RecreateBitmap(IDrawingContextImpl drawingContext, Size size, double scaling)
        {
            if (Size != size || Scaling != scaling)
            {
                var resized = RefCountable.Create(drawingContext.CreateLayer(size));

                using (var context = resized.Item.CreateDrawingContext(null))
                {
                    context.Clear(Colors.Transparent);
                    Bitmap.Dispose();
                    Bitmap  = resized;
                    Scaling = scaling;
                    Size    = size;
                    IsEmpty = true;
                }
            }
        }