Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/200.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android emulator的x,y位置获取像素颜色_Android_Colors_Android Emulator_Pixel - Fatal编程技术网

在Android emulator的x,y位置获取像素颜色

在Android emulator的x,y位置获取像素颜色,android,colors,android-emulator,pixel,Android,Colors,Android Emulator,Pixel,我在Android模拟器屏幕上有x,y位置。有没有办法在模拟器屏幕上找到这个特定x,y的像素颜色 可以,这是我在任何视图中获取特定像素的RGB值时使用的代码 view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap bitmap = view.getDrawingCache(); int pixel = bitmap.getPixel(x,y); int red = Color.red(pixel); int gr

我在Android模拟器屏幕上有x,y位置。有没有办法在模拟器屏幕上找到这个特定x,y的像素颜色

可以,这是我在任何视图中获取特定像素的RGB值时使用的代码

view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bitmap = view.getDrawingCache();

int pixel = bitmap.getPixel(x,y);

int red = Color.red(pixel);
int green = Color.green(pixel);
int blue = Color.blue(pixel);

view.setDrawingCacheEnabled(false);
返回的int值是标准的0-255。您可以修改此代码并从任何地方获取颜色,前提是您可以将其转换为位图。您可以使用获得实际RGB值,如下所示:

int rgb = Color.rgb(red, blue, green);

注意,这只会给你视图的像素-而不是屏幕是的,如我的答案的第一句所示。是的,但是“任何”视图也可以表示第三方视图-这是没有根的。我相信你知道,但由于OP要求屏幕而不是视图,我发现添加是有用的。考虑到他们提到了模拟器,唯一的替代答案是。就是你可以拍摄主机的屏幕截图,并使用图形软件来提取像素颜色。