Android上的外接显示器的屏幕截图? [英] Screen capture of external display on Android?
问题描述
Android应用程序通过 Presentation
类和相关工具,可以在外部显示器(HDMI,MHL,Miracast等)上显示单独的内容,而不是在手机或平板电脑自己的触摸屏上显示(我将在此处称为主要显示".
Android apps, via the Presentation
class and related facilities, can display separate content on an external display (HDMI, MHL, Miracast, etc.) than on a phone or tablet's own touchscreen (what I'll call the "primary display" here).
对于主显示,我们可以使用 screencap
或DDMS进行屏幕截图.
For the primary display, we can use screencap
or DDMS to do a screenshot.
有没有办法制作外部显示屏的屏幕截图?
Is there a way to do a screenshot of the external display?
理想情况下,这将是一种无需修改应用即可类似于 screencap
/DDMS的解决方案.但是,涉及以某种方式复制表示外部显示器的 Window
内容的解决方案也会很有趣.
Ideally, it would be a solution that could be used akin to screencap
/DDMS, with no app modifications. However, solutions that involve somehow copying the contents of the Window
representing the external display would also be interesting.
推荐答案
没有用于捕获外部显示的操作系统功能.
There is no OS feature for capturing the external display.
主显示由许多来源组成,外部显示也是如此.实际上,屏幕捕获"功能只是合成各种来源的另一种方法.因为它使用与主显示相同的参数,所以您将获得相同的输出.(但是,不会出现任何安全"层,例如受DRM保护的视频.)因此,要捕获"外部显示,您需要使用外部显示层堆栈"而不是屏幕捕获的变体.主要,并且没有API.
The main display is composited from a number of sources, as is the external display. The "screen capture" feature is actually just another way to composite the various sources. Because it uses the same parameters as the main display, you get the same output. (Note that any "secure" layers, such as DRM-protected video, do not appear however.) So to "capture" the external display, you'd want a screen capture variant that uses the external display "layer stack" rather than the main, and there is no API for doing so.
(请参见
The screenrecord
command does something similar: it creates a virtual display with the main display's layer stack, and captures whatever gets rendered there.
就捕获 Presentation
并使用 ImageReader ,而
As far as capturing the output of a Presentation
goes, there are a couple of CTS tests that may be of interest. The VirtualDisplayTest creates a Presentation
and captures it with an ImageReader, while EncodeVirtualDisplayTest feeds the Presentation through a full video encode/decode path. The tests just draw a series of colors and then check to make sure the colors can be read back. Both of these require recent very versions of Android (e.g. ImageReader
didn't exist until API 19), and the app's limited permissions will restrict the output to what the app itself is rendering.
这篇关于Android上的外接显示器的屏幕截图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!