- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我希望在没有 -p
标志的情况下使用 adb screencap
实用程序。我想象输出将以原始格式转储,但看起来不像。我尝试使用 Pillow
(python) 库打开原始图像文件的结果是:
$ adb pull /sdcard/screenshot.raw screenshot.raw
$ python
>>> from PIL import Image
>>> Image.open('screenshot.raw')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/....../lib/python2.7/site-packages/PIL/Image.py", line 2025, in open
raise IOError("cannot identify image file")
IOError: cannot identify image file
发现这样读取原始图像的方法不对,我什至试了一下:How to read a raw image using PIL?
>>> with open('screenshot.raw', 'rb') as f:
... d = f.read()
...
>>> from PIL import Image
>>> Image.frombuffer('RGB', len(d), d)
__main__:1: RuntimeWarning: the frombuffer defaults may change in a future release; for portability, change the call to read:
frombuffer(mode, size, data, 'raw', mode, 0, 1)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/..../lib/python2.7/site-packages/PIL/Image.py", line 1896, in frombuffer
return frombytes(mode, size, data, decoder_name, args)
File "/Users/..../lib/python2.7/site-packages/PIL/Image.py", line 1821, in frombytes
im = new(mode, size)
File "/Users/..../lib/python2.7/site-packages/PIL/Image.py", line 1787, in new
return Image()._new(core.fill(mode, size, color))
TypeError: must be 2-item sequence, not int
所有可能的模式选项都会导致相同的 TypeError
异常。
这是 hexdump
实用程序揭示的内容:
$ hexdump -C img.raw | head
00000000 d0 02 00 00 00 05 00 00 01 00 00 00 1e 1e 1e ff |................|
00000010 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff |................|
*
000038c0 1e 1e 1e ff 1e 1e 1e ff 21 21 21 ff 2b 2b 2b ff |........!!!.+++.|
000038d0 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff |................|
*
00004400 1e 1e 1e ff 1e 1e 1e ff 47 47 47 ff 65 65 65 ff |........GGG.eee.|
00004410 20 20 20 ff 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff | .............|
00004420 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff 1e 1e 1e ff |................|
*
在 OSX 上:
$ file screenshot.raw
screenshot.raw: data
screencap
帮助页面没有透露太多关于没有 -p
标志的输出数据的格式:
$ adb shell 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.
最佳答案
格式:
宽度
高度
pixel format
width
* heigth
* bytespp
) 字节作为字节数组 - 图像数据
,其中 bytespp
是每像素的字节数,取决于像素格式
。通常bytespp
为4。信息来自 source code of screencap .
以你的例子为例:
00000000 d0 02 00 00 00 05 00 00 01 00 00 00 1e 1e 1e ff
d0 02 00 00
- 宽度 - uint32 0x000002d0 = 72000 05 00 00
- 高度 - uint32 0x00000500 = 128001 00 00 00
- 像素格式 - uint32 0x00000001 = 1 = PixelFormat.RGBA_8888
=> bytespp = 4
=> RGBA<1e 1e 1e ff
- 第一个像素数据 - R = 0x1e; G = 0x1e; B = 0x1e; A = 0xff;
数据存储在大小为 720*1280*4 的字节数组中的像素。
关于android - "adb screencap/sdcard/screenshot.raw"产生什么格式? (没有 "-p"标志),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22034959/
我在 /data/data/files/settings.dat 中有一个文件并想将此文件存储/复制到 sdcard 中,该文件已被很好地读取但是当尝试将其复制到 sdcard 时,我有一个异常(ex
我只想知道如何在android模拟器中删除虚拟sdcard。 最佳答案 有了有关使用“rm -r *”系列命令的预期注意事项和警告,您还可以使用:adb -e shell rm -r/mnt/sdca
我正在尝试将位图保存到图片目录中。这是代码 File path = Environment.getExternalStoragePublicDirectory(Environm
我有一个很大的(50 兆)下载,如果已安装,我想将其加载到 SD 卡中。如果没有sdcard,我就下载到内部存储。我检查两种情况下的可用空间。 我的代码在模拟器和我的 Droid 2 上运行良好。我的
我快被一个奇怪的问题气疯了。如果我在我的代码中创建一个文件夹作为 directory_path = Environment.getExternalStorageDirectory()
我有一个特殊的问题,我有一个在启动完成时启动的 android 服务。服务完成从 sdcard 读取文件并将 pid 写入 sdcard 的工作,但是 .使用日志我知道原因是:无法将数据写入 sdca
我正在为 Yocto (Morty) 开发一个 sdcard 图像类,这基本上是直截了当的。必须在屋顶完成后构建 SD 卡镜像。 这可以由 IMAGE_TYPEDEP_sdcard 指示,在我的情况下
任何人都可以帮我解决 traceview 问题!我创建了 sdcard 并将其安装在我的模拟器上,关闭我的应用程序后,当我尝试拉取复制文件时(使用命令:adb pull/sdcard/calc.tra
我正在开发一个基本的音乐播放器,它将获取 SDCard 上的歌曲。它处于早期阶段,我遇到了一个小问题。每当我在手机上运行该应用程序时,它都能很好地播放 SDCard 上的歌曲。现在,当我在教师手机上运
我正在尝试将我在某些 Activity 中拥有的位图保存到我为此目的创建的目录中的外部存储。将图像保存到 sdcard(外部存储器,而不是外部 sd)的方法在不同的类(和不同的包)中,所以我假设我需要
我知道这个问题可能已经回答了很多次,我也进行了搜索,但我无法解决我的问题。每次我尝试写入 SD 卡时,它似乎都会写入内部存储。我的代码行很简单 File root = android.os.Envir
我想知道,是否可以在重新启动应用程序时暂停下载,退出应用程序并恢复从远程服务器下载文件到手机的 SDCard。 然后跟进问题:我有一个通过 HTTP 下载的代码。我也可以通过 FTP 完成吗?哪个更好
我的应用程序中有一个 Activity ,它基本上是一个画廊,显示位于我的 SD 卡上的图片。我正在使用此功能重新安装 sdcard 以在 Activity 开始时扫描新图像: sendBro
我想在 SD 卡上的特定文件夹中创建新文件时收到通知(通过广播)。我可以创建服务并为其轮询,但我更喜欢系统事件(如果存在的话)。 最佳答案 我找到了。 FileObserver会做的。 关于Andro
随着我应用中数据库的增长,它需要越来越多的内部手机空间。数据库中没有任何敏感/隐私数据,因此我有兴趣将其移至 SD 卡。 我正在使用 SQLiteOpenHelper 来协助数据库工作。据我了解,您不
我正在尝试将 Http 帖子回复中的文件写入 sdcard 上的文件。在检索到数据的字节数组之前,一切正常。 我尝试在 list 中设置 WRITE_EXTERNAL_STORAGE 权限并尝试了我在
我想在 Sdcard 中创建目录,并且我确实遵循: 我添加了:在 list 中。 我通过以下方式获取 root_path:public static final String ROOT_PATH =
我正在尝试使用以下代码在/storage/emulated/0/Pictures 下创建目录: File(Environment.getExternalStoragePublicDir
为什么Environment.getExternalStorageDirectory()返回内部存储(storage/sdcard0/)?就我而言,sdcard0 是本地的,sdcard1 是外部的.
我的对话框显示目录 /sdcard 及其所有文件。选择文件/图像后,路径将与位图图像一起保存,例如 file.name = "/sdcard/Pictures/Screenshots/Screensh
我是一名优秀的程序员,十分优秀!