Skip to content

Taking a screenshot in avalonia 11 #11669

Answered by maxkatz6
Varmod asked this question in Q&A
Discussion options

You must be logged in to vote

The only important part is RenderTargetBitmap, which is still public.

            var pixelSize = new PixelSize((int)target.Width, (int)target.Height);
            var size = new Size(target.Width, target.Height);
            var dpiVector = new Vector(dpi, dpi);

            using (RenderTargetBitmap bitmap = new RenderTargetBitmap(pixelSize, dpiVector))
            {
                target.Measure(size);
                target.Arrange(new Rect(size));
                bitmap.Render(target);
                bitmap.Save(immediatePath);
            }

or perhaps a way to directly access the last rendered frame?

No.

Replies: 1 comment 7 replies

Comment options

You must be logged in to vote
7 replies
@Varmod
Comment options

@ISDHN
Comment options

@rabbitism
Comment options

@ISDHN
Comment options

@rabbitism
Comment options

Answer selected by Varmod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
5 participants