/**
* configures the ProportionalTextureView to respect the aspect ratio of the image and using an appropriate buffer size
*/
@VisibleForTesting
void configureTextureView(@NonNull ProportionalTextureView textureView, @ConfigurationOrientation int deviceOrientation,
@SurfaceRotation int relativeDisplayRotation, @NonNull Size previewSize) {
switch (deviceOrientation) {
case Configuration.ORIENTATION_PORTRAIT:
// swap values because preview sizes are always landscape
textureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth(), relativeDisplayRotation);
break;
case Configuration.ORIENTATION_LANDSCAPE:
textureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight(), relativeDisplayRotation);
break;
}
// working more memory efficient
SurfaceTexture surface = textureView.getSurfaceTexture();
if (surface != null) {
surface.setDefaultBufferSize(previewSize.getWidth(), previewSize.getHeight());
} else {
throw new CameraException("surface texture not attached to view");
}
}
CameraHelper.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:BWS-Android
作者:
评论列表
文章目录