@Override
    protected float getScore(Size size, Size desired) {
        if (size.width <= 0 || size.height <= 0) {
            return 0f;
        }
        float scaleX = absRatio(size.width * 1.0f / desired.width);
        float scaleY = absRatio(size.height * 1.0f / desired.height);

        float scaleScore = 1.0f / scaleX / scaleY;

        float distortion = absRatio((1.0f * size.width / size.height) / (1.0f * desired.width / desired.height));

        // Distortion is bad!
        float distortionScore = 1.0f / distortion / distortion / distortion;

        return scaleScore * distortionScore;
    }
Get a score for our size.

Based on heuristics for penalizing scaling and cropping.

1.0 is perfect (exact match).
0.0 means we can't use it at all.

@param size the camera preview size (that can be scaled)
@param desired the viewfinder size
@return the score
zxing-android-embedded/src/com/journeyapps/barcodescanner/camera/FitXYStrategy.java