screencap 可以從 command line 擷取螢幕畫面。screencap [-p] [<FILENAME>]
提供 FILENAME 時表示要把畫面直接寫到手機的記憶卡,否則會輸出到 STDOUT。
加
加
-p 或 FILENAME 以 .png 結尾時,畫面會輸出成 PNG 格式(預設採用 frame buffer 的原始格式)。例如:$ adb shell screencap -p /sdcard/screen.png
$ adb pull /sdcard/screen.png
$ adb shell rm /sdcard/screen.png
利用
screencap 沒有給定 FILENAME 時會將畫面輸出到 STDOUT 的特性,可以將上面多個步驟合併成一行指令:$ adb shell screencap -p | sed 's/\r$//' > screen.png
後面用
sed 多做一層加工,是因為 adb shell 會將 \n 轉成 \r\n 的關係,必須將 \r\n (0x0d0a) 反轉回 \r (0x0a) 才行。實務上,再用 alias 包裝起來會比較方便:$ alias and-screencap="adb shell screencap -p | sed 's/\r$//'"
$ and-screencap > screen.png #
之後就可以用
and-screencap > <FILENAME> 直接將畫面存成電腦上的檔案 FILENAME,不需要在手機記憶卡產生暫存檔。完整的用法
$ screencap -h
usage: screencap [-hp] [FILENAME]
-h: this message
-p: save the file as a png.
If FILENAME ends with .png it will be saved as a png.
If FILENAME is not given, the results will be printed to stdout.
c语言代码片段学习编程
回覆刪除c代码斐波纳契数