Class PreviewScalingStrategy

    • Constructor Detail

      • PreviewScalingStrategy

        public PreviewScalingStrategy()
    • Method Detail

      • getBestPreviewSize

        public Size getBestPreviewSize​(List<Size> sizes,
                                       Size desired)
        Choose the best preview size, based on our viewfinder size. The default implementation lets subclasses calculate a score for each size, the picks the one with the best score. The sizes list may be reordered by this call.
        Parameters:
        sizes - supported preview sizes, containing at least one size. Sizes are in natural camera orientation.
        desired - The desired viewfinder size, in the same orientation
        Returns:
        the best preview size, never null
      • getBestPreviewOrder

        public List<Size> getBestPreviewOrder​(List<Size> sizes,
                                              Size desired)
        Sort previews based on their suitability. In most cases, getBestPreviewSize(List, Size) should be used instead. The sizes list may be reordered by this call.
        Parameters:
        sizes - supported preview sizes, containing at least one size. Sizes are in natural camera orientation.
        desired - The desired viewfinder size, in the same orientation
        Returns:
        an ordered list, best preview first
      • getScore

        protected float getScore​(Size size,
                                 Size desired)
        Get a score for our size. 1.0 is perfect (exact match). 0.0 means we can't use it at all. Subclasses should override this.
        Parameters:
        size - the camera preview size (that can be scaled)
        desired - the viewfinder size
        Returns:
        the score
      • scalePreview

        public abstract Rect scalePreview​(Size previewSize,
                                          Size viewfinderSize)
        Scale and position the preview relative to the viewfinder.
        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, relative to the viewfinder