예제 #1
0
        private void RenderComposite(Scene scene, ref IDrawingContextImpl context)
        {
            EnsureDrawingContext(ref context);

            context.Clear(Colors.Transparent);

            var clientRect = new Rect(scene.Size);

            var firstLayer = true;

            foreach (var layer in scene.Layers)
            {
                var bitmap     = Layers[layer.LayerRoot].Bitmap;
                var sourceRect = new Rect(0, 0, bitmap.Item.PixelSize.Width, bitmap.Item.PixelSize.Height);

                if (layer.GeometryClip != null)
                {
                    context.PushGeometryClip(layer.GeometryClip);
                }

                if (layer.OpacityMask == null)
                {
                    if (firstLayer && bitmap.Item.CanBlit)
                    {
                        bitmap.Item.Blit(context);
                    }
                    else
                    {
                        context.DrawBitmap(bitmap, layer.Opacity, sourceRect, clientRect);
                    }
                }
                else
                {
                    context.DrawBitmap(bitmap, layer.OpacityMask, layer.OpacityMaskRect, sourceRect);
                }

                if (layer.GeometryClip != null)
                {
                    context.PopGeometryClip();
                }

                firstLayer = false;
            }

            if (_overlay != null)
            {
                var sourceRect = new Rect(0, 0, _overlay.Item.PixelSize.Width, _overlay.Item.PixelSize.Height);
                context.DrawBitmap(_overlay, 0.5, sourceRect, clientRect);
            }

            if (DrawFps)
            {
                RenderFps(context, clientRect, scene.Layers.Count);
            }
        }
예제 #2
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();
        }
예제 #3
0
        public static WriteableBitmap ToWriteableBitmap(Bitmap bmp)
        {
            var wb = new WriteableBitmap(bmp.PixelSize, bmp.Dpi, PixelFormat.Bgra8888);

            using (IRenderTarget rtb = Utils.RenderInterface.CreateRenderTarget(new[] { new WriteableBitmapSurface(wb) }))
                using (IDrawingContextImpl ctx = rtb.CreateDrawingContext(null))
                {
                    var rect = new Rect(bmp.Size);
                    ctx.DrawBitmap(bmp.PlatformImpl, 1, rect, rect);
                }
            bmp.Dispose();
            return(wb);
        }
예제 #4
0
 /// <inheritdoc/>
 public override void Render(IDrawingContextImpl context)
 {
     context.Transform = Transform;
     context.DrawBitmap(Source, Opacity, SourceRect, DestRect, BitmapInterpolationMode);
 }
 public void Render(IDrawingContextImpl context, double opacity, Rect sourceRect, Rect destRect, BitmapInterpolationMode bitmapInterpolationMode = BitmapInterpolationMode.Default)
 {
     Read(b => context.DrawBitmap(_read.PlatformImpl, opacity, sourceRect, destRect, bitmapInterpolationMode));
     NotifyRendered();
 }