Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It lost something when I using Win2d render #37

Closed
HHChaos opened this issue Aug 6, 2018 · 3 comments
Closed

It lost something when I using Win2d render #37

HHChaos opened this issue Aug 6, 2018 · 3 comments

Comments

@HHChaos
Copy link
Contributor

HHChaos commented Aug 6, 2018

hi, I am using LottieUWP to develop a new uwp application, and I added a new method in your LottieDrawable class,so it can be rendered by win2d CanvasRenderTarget,but it doesnt work well,it lost something(for the following example its eyes).

I create a repository for display the problem:
https://github.com/HHChaos/LottieUwpTest

Added method in LottieDrawable.cs###

public CanvasCommandList GetCanvasImage(ICanvasResourceCreator resourceCreator, float scaleX, float scaleY)
    {
        lock (this)
        {
            var commandList = new CanvasCommandList(resourceCreator);
            using (var session = commandList.CreateDrawingSession())
            {
                var width = _composition.Bounds.Width * scaleX;
                var height = _composition.Bounds.Height * scaleY;
                if (_bitmapCanvas == null || _bitmapCanvas.Width < width || _bitmapCanvas.Height < height)
                {
                    _bitmapCanvas?.Dispose();
                    _bitmapCanvas = new BitmapCanvas(width, height);
                }

                using (_bitmapCanvas.CreateSession(resourceCreator.Device, (float) width,
                    (float) height, session))
                {
                    _bitmapCanvas.Clear(Colors.Transparent);
                    LottieLog.BeginSection("Drawable.Draw");
                    if (_compositionLayer == null)
                    {
                        return null;
                    }

                    _matrix.Reset();
                    _matrix = MatrixExt.PreScale(_matrix, scaleX, scaleY);
                    _compositionLayer.Draw(_bitmapCanvas, _matrix, _alpha);
                    LottieLog.EndSection("Drawable.Draw");
                }

            }

            return commandList;
        }
    }
@ChrisShaoMeng
Copy link

Hi @azchohfi , HHChaos is my teammate and we are developing the 'Letsdraw' UWP App, Which used Win2D to render hand-drawing and 2d animation. And in this version we added support for Lottie element, so we tried to use LottieUWP and Win2D to render it, but it doesn't work well in HHChaos' issue. So please help us to check if there are some issues in our code, or should we use this method to render it with LottieUWP and Win2D, Thanks!

@HHChaos
Copy link
Contributor Author

HHChaos commented Oct 23, 2018

@azchohfi
This problem has been solved, you can closed this issue.
The bug appeared to be related to the CanvasCommandList infinite size, and when I replaced it with the CanvasRenderTarget, it work well!

@azchohfi
Copy link
Owner

Perfect! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants