简体   繁体   中英

Capture screen of the application on a Windows 10 Universal App

I need to capture the screen of my application to save it on the device. Is it possible with a Windows 10 Universal App?

If your app runs specifically on phones then it can use the ScreenCapture class from the Phone Contract. This isn't available on other device families.

On other devices you can capture the apps own window contents (but not others) by rendering it into an offscreen bitmap. For a Xaml app use the RenderTargetBitmap class to render the root of the page.

RenderTargetBitmap renderTargetBitmap = new RenderTargetBitmap(); 
await renderTargetBitmap.RenderAsync(pageRoot, width, height); 

Extract the image with GetPixelsAsync, encode to a bitmap (jpg, png, etc) with a BitmapEncoder then save or share the results.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM