我正在截屏并将其转换为位图
Bitmap bitmap = null;
while (bitmap == null) { bitmap = BitmapFactory.decodeFile(path/filename.png); }
然后我要获得像素颜色
int pixel = bitmap.getPixel(x, y);
Log.i("Main", "color: " + "#" + Integer.toHexString(pixel));
且有效,但仅当y <130时有效。当y 140或更大时,我只会得到黑色
2020-06-01 14:43:46.121 17451-17495/com. I/Main: color: #ff000000
屏幕截图分辨率为1920 * 1080。当我尝试将其加载到ImageView中时一切正常
答案 0 :(得分:0)
对我来说,要像这样截屏
Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/bin/screencap -p " + "/sdcard/img.png").getBytes("ASCII"));
os.flush();
os.close();
sh.waitFor();