Class LegacyPreviewScalingStrategy
- java.lang.Object
-
- com.journeyapps.barcodescanner.camera.PreviewScalingStrategy
-
- com.journeyapps.barcodescanner.camera.LegacyPreviewScalingStrategy
-
public class LegacyPreviewScalingStrategy extends PreviewScalingStrategy
-
-
Constructor Summary
Constructors Constructor Description LegacyPreviewScalingStrategy()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description SizegetBestPreviewSize(List<Size> sizes, Size desired)Choose the best preview size, based on our display size.static Sizescale(Size from, Size to)Scale from so that to.fitsIn(size).RectscalePreview(Size previewSize, Size viewfinderSize)Scale the preview to cover the viewfinder, then center it.-
Methods inherited from class com.journeyapps.barcodescanner.camera.PreviewScalingStrategy
getBestPreviewOrder, getScore
-
-
-
-
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:
getBestPreviewSizein classPreviewScalingStrategy- 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 sizeto- 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:
scalePreviewin classPreviewScalingStrategy- Parameters:
previewSize- the size of the preview (camera), in current display orientationviewfinderSize- the size of the viewfinder (display), in current display orientation- Returns:
- a rect placing the preview
-
-