title: I have made a camera view app, I want the output of the image to be exactly as it is shown in the view
body: <p>You can see below the android view image differs from the output image, I want the output image exactly same as it is shown in the android view. I want to do this because in future I will add a box in the center and I can find the box position in the android view and I will use this position to cut out the image from the output image.</p>
  <p>This is the code-&gt;</p>
  <pre><code> @Composable
  fun CameraView(
      isOpenFrontCamera: Boolean,
      outputDirectory: File,
      executor: Executor,
      onImageCaptured: (Uri) -&gt; Unit,
      onError: (ImageCaptureException) -&gt; Unit,
      onCloseCameraClick: () -&gt; Unit
  ) {
      val lensFacing: Int =
          if (isOpenFrontCamera) CameraSelector.LENS_FACING_FRONT else CameraSelector.LENS_FACING_BACK
      val context = LocalContext.current
      val lifecycleOwner = LocalLifecycleOwner.current
  
      val preview = Preview.Builder().build()
      val previewView = remember { PreviewView(context) }
  
      val imageCapture: ImageCapture = remember {
          ImageCapture.Builder().setCaptureMode(ImageCapture.CAPTURE_MODE_MAXIMIZE_QUALITY).build()
      }
  
      val cameraSelector = CameraSelector.Builder()
          .requireLensFacing(lensFacing)
          .build()
  
      LaunchedEffect(lensFacing) {
          val cameraProvider = context.getCameraProvider()
          cameraProvider.unbindAll()
          cameraProvider.bindToLifecycle(
              lifecycleOwner,
              cameraSelector,
              preview,
              imageCapture
          )
  
          preview.setSurfaceProvider(previewView.surfaceProvider)
      }
  
      //Screen
      Box(
          contentAlignment = Alignment.BottomCenter,
          modifier = Modifier
              .fillMaxSize()) {
          AndroidView({ previewView }, modifier = Modifier.fillMaxSize())
  
          IconButton(
              modifier = Modifier.padding(bottom = 20.dp),
              onClick = {
                  Log.d(&quot;takePhoto&quot;, &quot;ON CLICK&quot;)
                  takePhoto(
                      imageCapture = imageCapture,
                      outputDirectory = outputDirectory,
                      executor = executor,
                      onImageCaptured = { imageUri -&gt;
                              onImageCaptured(imageUri)
                      },
                      onError = onError
                  )
              },
              content = {
                  Icon(
                      painter = painterResource(id = R.drawable.ic_baseline_camera_24),
                      contentDescription = stringResource(R.string.take_picture),
                      tint = Color.White,
                      modifier = Modifier
                          .fillMaxSize(0.2f)
                  )
              }
          )
      }
  }
  
    
  </code></pre>
  <p><strong>Application -&gt;</strong></p>
  <p><a href="https://i.stack.imgur.com/DAlFu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DAlFu.png" alt="enter image description here" /></a></p>
  <p><strong>Output-&gt;</strong></p>
  <p><a href="https://i.stack.imgur.com/aroKA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aroKA.jpg" alt="enter image description here" /></a></p>