Class LegacyPreviewScalingStrategy

    • Constructor Detail

      • LegacyPreviewScalingStrategy

        public LegacyPreviewScalingStrategy()
    • Method Detail

      • getBestPreviewSize

        public Size getBestPreviewSize​(List<Size> sizes,
                                       Size desired)
        Choose the best preview size, based on our display size. We prefer: 1. no scaling 2. least downscaling 3. least upscaling We do not care much about aspect ratio, since we just crop away extra pixels. We only choose the size to minimize scaling. In the future we may consider choosing the biggest possible preview size, to maximize the resolution we have for decoding. We need more testing to see whether or not that is feasible.
        Overrides:
        getBestPreviewSize in class PreviewScalingStrategy
        Parameters:
        sizes - supported preview sizes, containing at least one size. Sizes are in natural camera orientation.
        desired - The desired display size, in the same orientation
        Returns:
        the best preview size, never null
      • scale

        public static Size scale​(Size from,
                                 Size to)
        Scale from so that to.fitsIn(size). Tries to scale by powers of two, or by 3/2. Aspect ratio is preserved. These scaling factors will theoretically result in fast scaling with minimal quality loss. TODO: confirm whether or not this is the case in practice.
        Parameters:
        from - the start size
        to - the minimum desired size
        Returns:
        the scaled size
      • 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