我的目标是能够输入一个单词的命令,并从通过USB附加的根Nexus one中获得屏幕截图。
到目前为止,我可以通过如下方式获取帧缓冲区,我认为它是一个32bit xRGB888
原始图像:
adb pull /dev/graphics/fb0 fb0
不过,从那时起,我很难将其转换为png。我尝试这样使用ffmpeg:
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb8888 -s 480x800 -i fb0 -f image2 -vcodec png image.png
这创建了一个可爱的紫色图像,它的某些部分与屏幕有些相似,但它绝不是一个干净的屏幕截图。
发布于 2012-08-03 23:43:10
对于ICS,一个简单得多的解决方案是从命令行使用以下命令
adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png screenshot.png
这会将screenshot.png文件保存在当前目录中。
已在运行4.0.3的三星Galaxy SII和SII上测试。
发布于 2012-02-16 20:26:00
实际上,还有另一种非常简单的方法可以从你的安卓设备上抓取屏幕截图:像这样编写简单的脚本1.script
:
# Imports the monkeyrunner modules used by this program
from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
# Connects to the current device, returning a MonkeyDevice object
device = MonkeyRunner.waitForConnection()
# Takes a screenshot
result = device.takeSnapshot()
# Writes the screenshot to a file
result.writeToFile('1.png','png')
然后打电话给monkeyrunner 1.script
。
发布于 2010-07-19 21:25:30
N1的帧缓冲似乎使用了RGB32编码(每像素32位)。
下面是我使用ffmpeg的脚本:
adb pull /dev/graphics/fb0 fb0
dd bs=1920 count=800 if=fb0 of=fb0b
ffmpeg -vframes 1 -vcodec rawvideo -f rawvideo -pix_fmt rgb32 -s 480x800 -i fb0b -f image2 -vcodec png fb0.png
从这里描述的ADP1方法派生的另一种方法http://code.lardcave.net/entries/2009/07/27/132648/
adb pull /dev/graphics/fb0 fb0
dd bs=1920 count=800 if=fb0 of=fb0b
python rgb32torgb888.py <fb0b >fb0b.888
convert -depth 8 -size 480x800 RGB:fb0b.888 fb0.png
Python脚本'rgb32torgb888.py':
import sys
while 1:
colour = sys.stdin.read(4)
if not colour:
break
sys.stdout.write(colour[2])
sys.stdout.write(colour[1])
sys.stdout.write(colour[0])
https://stackoverflow.com/questions/2807070
复制相似问题