CameraHelper.java 文件源码

java
阅读 34 收藏 0 点赞 0 评论 0

项目:BWS-Android 作者:
/**
 * 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");
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号