w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
get pixel color in Android emulator at x,y position

Yes you can, this is the code I use the get the RGB value of a specific pixel in any view.

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);

The int values returned are your standard 0 - 255. You can modify this code and get a color from anywhere, providing you can turn it into a bitmap. And you can use the Color API to get an actual RGB value like this:

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




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.