【发布时间】:2020-08-10 22:51:05
【问题描述】:
我正在使用HelloAR demo application,我正在尝试截取整个屏幕(菜单栏和所有内容)。我可以截取屏幕截图,但并非所有内容都被捕获... GUI 元素在屏幕截图中可见,但摄像头馈送不可见。
这是我的代码:
int counter = 0;
private void takeScreenShot()
{
View view = getWindow().getDecorView().getRootView();
Bitmap bmp = Bitmap.createBitmap(view.getWidth(), view.getHeight(), Bitmap.Config.ARGB_8888);
PixelCopy.request(getWindow(), bmp, copyResult -> {
if(copyResult == PixelCopy.SUCCESS){
String filename = getExternalFilesDir(null) + File.separator + "SCREENSHOTS" + File.seperator + "SS_" + counter + ".png";
store(bmp, filename);
counter++;
}
}, new Handler());
}
public static void storeit(Bitmap bm, String fileName){
File file = new File(fileName);
try {
FileOutputStream fOut = new FileOutputStream(file);
bm.compress(Bitmap.CompressFormat.PNG, 85, fOut);
fOut.flush();
fOut.close();
} catch (Exception e) {
e.printStackTrace();
}
}
截图如下:
如何捕获整个屏幕(摄像头、UI 元素、菜单栏等)?
【问题讨论】:
标签: android screenshot arcore screen-capture