我怎样才能得到一个屏幕像素亚行的颜色 [英] How can I get the color of a screen pixel THROUGH ADB

查看:466
本文介绍了我怎样才能得到一个屏幕像素亚行的颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的Andr​​oid手机屏幕的特定点的颜色信息。

I need to get the color information of a specific point on screen of my android phone.

有没有办法做到这一点通过亚行?

Is there a way to do that through ADB?

我现在使用内置的命令screencap捕捉整个屏幕,然后读取特定点的颜色。然而,这是太慢了。

I am now using the build-in command screencap to capture the whole screen and then read the color of the specific point. However, it is too slow.

推荐答案

我会后回答我自己的问题。答案或许设备指定(nexus7 2013),并可以将其调整到你自己的设备。

I will post an answer to my own question. The answer maybe device-specified (nexus7 2013), and you can adjust it to your own devices.

1.Firstly,我发现该命令 screencap screen.png 是相当缓慢的,因为它承担大部分时间转换为PNG文件类型。因此,为了节省时间,第一步骤是转储屏幕到一个原始数据文件。 亚行的shell screencap screen.dump

1.Firstly, I find out that the command screencap screen.png is quite slow because it take most of its time converting to png file type. So, to save time, the first step is dump screen to a raw data file. adb shell screencap screen.dump

2.检查文件的大小。我的屏幕分辨率为1920 * 1200,文件大小为9216012字节。我注意到9216012 = 1920 * 1200 * 4 + 12,我猜的数据文件,请使用4个字节来存储每一个像素的信息,并使用另一个12字节做一些神秘的工作人员。只是做一些更多的screencaps,我发现了12个字节的每个文件的开头都是一样的。所以,附加12字节是在数据文件的开头。

2.Check the file size. My screen resolution is 1920*1200, and the file size is 9216012 byte. Noticing that 9216012=1920*1200*4+12, I guess the data file use 4 byte to store every pixel information, and use another 12 byte to do some mystery staff. Just do some more screencaps and I find the 12 byte at the head of each file are the same. So, the additional 12 byte is at the head of the data file.

3.Now,事情是通过使用 DD HD 简单。假设我想在(X,Y)颜色: 让偏移= 1200 * $ Y + $ X + 3 DD如果='screen.dump'BS = 4计数= 1跳过= $偏移2>的/ dev / null的|高清

3.Now, things are simple by using dd and hd. Assuming that I want to get the color at (x,y): let offset=1200*$y+$x+3 dd if='screen.dump' bs=4 count=1 skip=$offset 2>/dev/null | hd

我得到这样的输出 00000000:4B 73 61 FF小号21E 总之21E 4B 73 61 FF 就是我的回答。

I get output like 00000000: 4b 73 61 ff s 21e sum 21e The 4b 73 61 ff is my answer.

这篇关于我怎样才能得到一个屏幕像素亚行的颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆