我有这段代码可以打开fefault相机
Intent camera = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(camera, CAMERA_REQUEST);
这是用于捕捉照片
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Bitmap bitmap = (Bitmap) Objects.requireNonNull(data.getExtras()).get("data");
ByteArrayOutputStream stream=new ByteArrayOutputStream();
assert bitmap != null;
bitmap.compress(Bitmap.CompressFormat.PNG,100,stream);
byte[] imageBytes=stream.toByteArray();
sendReceive.write(String.valueOf(imageBytes.length).getBytes());
int subArraySize=400;
for(int i=0;i<imageBytes.length;i+=subArraySize){
byte[] tempArray;
tempArray= Arrays.copyOfRange(imageBytes,i,Math.min(imageBytes.length,i+subArraySize));
sendReceive.write(tempArray);
}
}
我有一个问题,如何捕捉相机预览框?