Jay Patel
Jay Patel

Reputation: 353

How to change pictureResolution in Fotoapparat Camera?

I'm using Fotoapparat library. But i didn't find how to set desire pictureResolution in configuration. i only get two option highestResolution() and lowestResolution(). How can i set pictureResolution which i want in configuration. Any help will be grateful.

Upvotes: 0

Views: 1019

Answers (1)

Diolor
Diolor

Reputation: 13450

Not all cameras support a specifically desired resolution.

E.g. you wish to take pictures of 1280x720. Some phones will not support it but support only lower ones, e.g. VGA.

What you can do is to ask the phone which resolutions support and then select you desired one from the list:

CameraConfiguration(    
   pictureResolution = { availableResolutions ->
    // pick by returning here a non-null resolution from the set of 'availableResolutions'
   },
   ...
)

The API is extremely flexible.

You can get creative like: "Try capture a 1280x720. If you can't, get the highest one".

CameraConfiguration(   
    pictureResolution = firstAvailable(
     { Resolution(1280,720) },
     highestResolution()
    )
)

Upvotes: 3

Related Questions