CameraBridgeViewBase.java 文件源码

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

项目:Android-Code-Demos 作者:
/**
 * This helper method can be called by subclasses to select camera preview size.
 * It goes over the list of the supported preview sizes and selects the maximum one which
 * fits both values set via setMaxFrameSize() and surface frame allocated for this view
 * @param supportedSizes
 * @param surfaceWidth
 * @param surfaceHeight
 * @return optimal frame size
 */
protected Size calculateCameraFrameSize(List<?> supportedSizes, ListItemAccessor accessor, int surfaceWidth, int surfaceHeight) {
    int calcWidth = 0;
    int calcHeight = 0;

    int maxAllowedWidth = (mMaxWidth != MAX_UNSPECIFIED && mMaxWidth < surfaceWidth)? mMaxWidth : surfaceWidth;
    int maxAllowedHeight = (mMaxHeight != MAX_UNSPECIFIED && mMaxHeight < surfaceHeight)? mMaxHeight : surfaceHeight;

    for (Object size : supportedSizes) {
        int width = accessor.getWidth(size);
        int height = accessor.getHeight(size);

        if (width <= maxAllowedWidth && height <= maxAllowedHeight) {
            if (width >= calcWidth && height >= calcHeight) {
                calcWidth = (int) width;
                calcHeight = (int) height;
            }
        }
    }

    return new Size(calcWidth, calcHeight);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号