RedApparat / Fotoapparat

Making Camera for Android more friendly. 📸
Apache License 2.0
3.82k stars 407 forks source link

How do we enable zoom in & zoom out using configurations ? #371

Open shrikantsonar opened 5 years ago

shrikantsonar commented 5 years ago

Used following code to configure fotoapparat.

private fun configureFotoApparat() {

    val cameraConfiguration = CameraConfiguration(

            pictureResolution = highestResolution(), // (optional) we want to have the highest possible photo resolution
            previewResolution = highestResolution(), // (optional) we want to have the highest possible preview resolution
            previewFpsRange = highestFps(),          // (optional) we want to have the best frame rate
            focusMode = firstAvailable(              // (optional) use the first focus mode which is supported by device
                    continuousFocusPicture(),
                    autoFocus(),                       // if continuous focus is not available on device, auto focus will be used
                    fixed()                            // if even auto focus is not available - fixed focus mode will be used
            ),
            flashMode = firstAvailable(              // (optional) similar to how it is done for focus mode, this time for flash
                    autoRedEye(),
                    autoFlash(),
                    torch(),
                    off()
            ),
            antiBandingMode = firstAvailable(       // (optional) similar to how it is done for focus mode & flash, now for anti banding
                    auto(),
                    hz50(),
                    hz60(),
                    none()
            ),
            jpegQuality = manualJpegQuality(30),     // (optional) select a jpeg quality of 90 (out of 0-100) values
            sensorSensitivity = lowestSensorSensitivity() // (optional) we want to have the lowest sensor sensitivity (ISO)
    )

    fotoapparat = Fotoapparat(
            context = this,
            view = camera_view,                   // view which will draw the camera preview
            scaleType = ScaleType.CenterCrop,    // (optional) we want the preview to fill the view
            lensPosition = back(), // (optional) we want back camera
            cameraConfiguration = cameraConfiguration,
            cameraErrorCallback = { error -> logger.error("###", error.localizedMessage) }   // (optional) log fatal errors
    )

}