Thursday, 28 November 2019

Why can't CameraX zooom in a picture as larger as I need in Android Studio?

I'm learning CameraX, and CameraXBasic is sample code.

I write a zoomX function based CameraFragment.kt. you can see the Code A. I think the function can zoom in a picture any times.

I find that a picture can be zoom in when I invoke it with s a small value, such as zoomX(2f), zoomX(3f), but the picture will not be zoom in again when I use a big value such as zoomX(6.0f), zoomX(7.0f)... why?

Code A

   private lateinit var viewFinder: TextureView 
    private var preview: Preview? = null

    fun zoomX(orign: Float ){       
        val x=orign+1

        val singleWidth=viewFinder.width/x
        val singleHeight=viewFinder.height/x

        val left=viewFinder.width/2f-singleWidth/2f
        val right=left+singleWidth
        val top=viewFinder.height/2f-singleHeight/2f
        val bottom=top+singleHeight

        val my= Rect(left.toInt(), top.toInt(), right.toInt(), bottom.toInt())
        preview?.zoom(my)      
    }


from Why can't CameraX zooom in a picture as larger as I need in Android Studio?

No comments:

Post a Comment