Android:有没有办法从内存中读取屏幕截图而不保存到内部/外部存储? [英] Android: It there a way to read screenshot from memory without saving to internal/external storage?
问题描述
我知道有办法以编程方式截取屏幕截图。
1.通过ADB使用MonkeyRunner并使用USB线连接PC和Android设备之间的连接。
http://developer.android.com/tools/help/MonkeyDevice.html#takeSnapshot
2.从您开发的APP的绘图缓存中获取
https:// stackoverflow .com / a / 24280494/2080233
3.从帧缓冲区获取,但不能用于许多应用程序。
http://www.pocketmagic.net/android-native-screen-capture-application-using -the-framebuffer /
4.按root使用/ system / bin / screencap,但需要写入存储空间。
https://stackoverflow.com/a/ 15208592/2080233
I know there are ways to take screenshot programmatically.
1. use MonkeyRunner through ADB and use USB cable for connection between PC and Android device.
http://developer.android.com/tools/help/MonkeyDevice.html#takeSnapshot
2. get from drawing cache for your developed APP only
https://stackoverflow.com/a/24280494/2080233
3. get from frame buffer, but not work for many app.
http://www.pocketmagic.net/android-native-screen-capture-application-using-the-framebuffer/
4. use /system/bin/screencap by root, but need to write into storage.
https://stackoverflow.com/a/15208592/2080233
我想知道是否有办法直接从内存中获取屏幕截图并且运行良好。
I want to know if there is a way to grab a screenshot directly from memory and work great.
推荐答案
您对#4的分析不太准确,因为 screencap
的使用信息指出:
Your analysis of #4 is not quite accurate, as the usage information for screencap
states:
如果没有给出FILENAME,结果将打印到stdout
If FILENAME is not given, the results will be printed to stdout
因此如果你可以作为具有足够权限的用户调用 screencap
,你可以捕获进程的输出并根据这些数据做任何你喜欢的事情。
Therefore if you can invoke screencap
as a user with sufficient permissions, you can capture the output of the process and do whatever you like with that data.
我相信这就是DDMS最终的屏幕截图按钮,通过adb连接管理数据。但请注意,如果您通过ADB的标准输出传递二进制数据,则可能必须撤消在Windows用户的可疑考虑中插入的CRLF转换。
I believe this is what the screenshot button in DDMS ultimately does, piping the data back through the adb connection. Note however that if you pass binary data by way of ADB's standard output, you may have to undo a CRLF translation inserted in dubious consideration of Windows users.
这篇关于Android:有没有办法从内存中读取屏幕截图而不保存到内部/外部存储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!