I want to capture photos with fixed resolution (i.e. 1200x1600
) using CameraX library.
So according to documentation I can set target resolution for ImageCaptureConfig
:
val imageCaptureConfig = ImageCaptureConfig.Builder()
.setLensFacing(CameraX.LensFacing.BACK)
.setCaptureMode(ImageCapture.CaptureMode.MAX_QUALITY)
.setTargetResolution(Size(1200, 1600))
.setTargetAspectRatio(Rational(3,4))
.build()
Documentation describes setTargetResolution
method as follows:
Sets the intended output target resolution.
The target resolution attempts to establish a minimum bound for the image resolution. The actual image resolution will be the closest available resolution in size that is not smaller than the target resolution, as determined by the Camera implementation. However, if no resolution exists that is equal to or larger than the target resolution, the nearest available resolution smaller than the target resolution will be chosen.
Correct me if I am wrong, but if device is able to take photos larger than 1200x1600
(e.g. 3024x4032
), the output photo will be at least 1200x1600
.
Unfortunately in many devices (e.g. Huawei P20 Pro
, Samsung A5
) the output photo is significantly smaller than 1200x1600
, e.g. 480x640
. Notice that these devices are able to take really large photos.
Is my ImageCaptureConfig
badly configured or this is a bug?