【发布时间】:2019-11-01 20:28:14
【问题描述】:
我正在尝试截取我的增强现实屏幕截图并将其作为位图传递给另一个活动。
这是我用来截屏的代码:
截屏功能
public static void tmpScreenshot(Bitmap bmp, Context context){
try {
//Write file
String filename = "bitmap.png";
FileOutputStream stream = context.openFileOutput(filename, Context.MODE_PRIVATE);
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
//Cleanup
stream.close();
bmp.recycle();
//Pop intent
Intent in1 = new Intent(context, CostActivity.class);
in1.putExtra("image", filename);
context.startActivity(in1);
} catch (Exception e) {
e.printStackTrace();
}
}
接收截图功能
private void loadTmpBitmap() {
Bitmap bmp = null;
String filename = getIntent().getStringExtra("image");
try {
FileInputStream is = this.openFileInput(filename);
bmp = BitmapFactory.decodeStream(is);
ImageView imageView = findViewById(R.id.test);
imageView.setImageBitmap(Bitmap.createScaledBitmap(bmp, 120, 120, false));
is.close();
} catch (Exception e) {
e.printStackTrace();
}
}
}
即使截取了屏幕截图,当它被传递给另一个活动时它还是黑色的。 另外,屏幕截图只有在我按下后退按钮后才会出现
任何人都可以帮助我使用 ARCore 截取屏幕截图的代码吗?还是我做错了什么?
【问题讨论】:
-
经过进一步研究,我发现我必须在表面视图上拍照。与此相关的一些现有问题:stackoverflow.com/questions/25086263/…stackoverflow.com/questions/27817577/…
标签: java android screenshot arcore sceneform