Class FitCenterStrategy
- java.lang.Object
-
- com.journeyapps.barcodescanner.camera.PreviewScalingStrategy
-
- com.journeyapps.barcodescanner.camera.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 Summary
Constructors Constructor Description FitCenterStrategy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected floatgetScore(Size size, Size desired)Get a score for our 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, getBestPreviewSize
-
-
-
-
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:
getScorein classPreviewScalingStrategy- 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:
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
-
-