Android 设备上截图使用哪些命令行(screencap 除外)

Sab*_*mni 3 screenshot

我想使用命令行截取已 root 的三星设备的屏幕截图。我时间有限,不能超过2秒。所以我的问题是如何使用命令行截取屏幕截图。

Oce*_*ans 6

可以使用以下命令来截取屏幕截图。

adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png
Run Code Online (Sandbox Code Playgroud)

来源


更新:经过一些研究,我注意到一个类似的问题,它的答案可能会对您有所帮助:

如果慢的部分是 raw 到 png 的转换(time adb shell screencap -p /sdcard/x.png比 慢得多time adb shell screencap /sdcard/nonpng.raw,就像我在游戏中那样)

max_plenert 的这个 shell 脚本是一个更好的例子:

adb shell screencap /sdcard/mytmp/rock.raw
adb pull /sdcard/mytmp/rock.raw
adb shell rm /sdcard/mytmp/rock.raw

// remove the header
tail -c +13 rock.raw > rock.rgba

// extract width height and pixelformat:
hexdump -e '/4 "%d"' -s 0 -n 4 rock.raw
hexdump -e '/4 "%d"' -s 4 -n 4 rock.raw
hexdump -e '/4 "%d"' -s 8 -n 4 rock.raw

convert -size 480x800 -depth 8 rock.rgba rock.png
Run Code Online (Sandbox Code Playgroud)

来源