简体   繁体   English

在Windows 10 Universal App上捕获应用程序的屏幕

[英]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? Windows 10通用应用程序可以吗?

If your app runs specifically on phones then it can use the ScreenCapture class from the Phone Contract. 如果您的应用专门在电话上运行,则可以使用“电话合同”中的ScreenCapture类。 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. 对于Xaml应用程序,请使用RenderTargetBitmap类呈现页面的根。

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. 使用GetPixelsAsync提取图像,使用BitmapEncoder编码为位图(jpg,png等),然后保存或共享结果。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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