Class FitCenterStrategy


  • public class FitCenterStrategy
    extends PreviewScalingStrategy
    Scales the size so that both dimensions will be greater than or equal to the corresponding dimension of the parent. One of width or height will fit exactly. Aspect ratio is preserved.
    • Constructor Detail

      • FitCenterStrategy

        public FitCenterStrategy()
    • Method Detail

      • getScore

        protected float getScore​(Size size,
                                 Size desired)
        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.
        Overrides:
        getScore in class PreviewScalingStrategy
        Parameters:
        size - the camera preview size (that can be scaled)
        desired - the viewfinder size
        Returns:
        the score
      • scalePreview

        public Rect scalePreview​(Size previewSize,
                                 Size viewfinderSize)
        Scale the preview to cover the viewfinder, then center it. Aspect ratio is preserved.
        Specified by:
        scalePreview in class PreviewScalingStrategy
        Parameters:
        previewSize - the size of the preview (camera), in current display orientation
        viewfinderSize - the size of the viewfinder (display), in current display orientation
        Returns:
        a rect placing the preview