我在 Android Studio 中使用带有三星 S10+ 的相机 2 拍摄和保存照片的过程中发现了一个错误。
安卓版本:11
内核版本:4.14。113-22340597
final CaptureRequest.Builder captureBuilder = cameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.addTarget(reader.getSurface());
captureBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO);
int rotation = getWindowManager().getDefaultDisplay().getRotation();
captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
Long tsLong = System.currentTimeMillis() / 1000;
String ts = tsLong.toString();
file = new File(Environment.DIRECTORY_DOWNLOADS, ts + ".jpg");
ImageReader.OnImageAvailableListener readerListener = new ImageReader.OnImageAvailableListener() {
@Override
public void onImageAvailable(ImageReader reader) {
Image image = null;
image = reader.acquireLatestImage();
ByteBuffer buffer = image.getPlanes()[0].getBuffer();
byte[] bytes = new byte[buffer.capacity()];
buffer.get(bytes);
try {
save(bytes);
} catch (IOException e) {
e.printStackTrace();
} finally {
if (image != null) {
image.close();
}
}
}
};
而且...这是错误结果
E/ExynosCameraNode: [CAM(0)][FLITE]-(m_dqBuf[1660]):exynos_v4l2_dqbuf(fd:29) 失败 (-1)
E/ExynosCameraMCPipe: [CAM(0)][PIPE_3AA]-(m_getBuffer[2118]):node(FLITE)->getBuffer() 失败, index(-2), frameCount(7), ret(-1)
E/ExynosCameraFrame: [CAM(-1)][]-(setSrcBuf[3233]):无效缓冲区状态(3)
E/ExynosCameraFrame: [CAM(0)][]-(setSrcBuffer[273]): 无法设置 src 缓冲区,ret(-38)
E/ExynosCameraMCPipe: [CAM(0)][PIPE_3AA]-(m_getBuffer[2154]):0's setSrcBuffer fail, fCount(7), pipe(5), ret(-38)
E/IndicatorGardenAlgorithmBasicCutout: NOT MATCH !!!! resourceHeight:108, cutoutHeight:107 ([IndicatorGardenInputProperty] Rotation(0-0,90-1,180-2,270-3)0, Density:2.625, ScreenWidthSize:1080, CoverSidePadding:0, mIndicatorGardenCenterOffset:11, mCameraCutoutCropSize:0, mGardenPaddingStart:21 , mIndicatorCornerPadding:56, mCameraSidePadding:25, mCameraTopMargin:24, DpCutout:DisplayCutout{insets=Rect(0, 107 - 0, 0) 瀑布=Insets{left=0, top=0, right=0, bottom=0} boundingRect ={Bounds=[矩形(0, 0 - 0, 0), 矩形(836, 0 - 1080, 107), 矩形(0, 0 - 0, 0), 矩形(0, 0 - 0, 0)]} })