Android 系统自带截屏命令 screencap,其可执行文件位于:/system/bin/ ,源码位于:frameworks/base/cmds/screencap 。
查看帮助
可以使用 screencap -h 命令查看帮助信息。
D:\log>adb shell screencap -h
usage: screencap [-hp] [-d display-id] [FILENAME]
-h: this message
-p: save the file as a png.
-d: specify the physical display ID to capture (default: 59)
see "dumpsys SurfaceFlinger --display-id" for valid display IDs.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
解释
用法: screencap [-hp] [-d 显示id] [文件名]
-h: 查看帮助信息
-p: 保存文件为png格式
-d: 指定截取的显示id,默认为fb0(fb为framebuffer)
如果文件名以.png结束,将保存为png格式文件
如果没有文件名,将直接打印到标准输出
使用说明
1. 截取fb0界面到sdcard,并导入到电脑,可以进行查看。
adb shell screencap -p sdcard/fb0.png
adb pull /sdcard/fb0.png
adb shell rm /sdcard/fb0.png
2. 截取fb1界面到sdcard,文件名为fb1.png
adb shell screencap -d /dev/graphics/fb1 sdcard/fb1.png
本文详细介绍了Android系统内置的截屏命令`screencap`的用法、参数解析以及实际应用场景,包括默认行为、保存格式和指定显示设备。
814

被折叠的 条评论
为什么被折叠?



