Android SurfaceView Mirror camera

Viewed 142

I want to mirror a preview in a rear camera. Not to rotate a view but flip the view. I am using surfaceView. any help will be Appreciated. enter image description here

1 Answers

You can flip the image of bitmap using prescale properties of Matrix. example:

val rotateMatrix = Matrix() rotateMatrix.postRotate(0.0f) 
 rotateMatrix.preScale(-1.0f, 1.0f)

val rotatedBitmap = Bitmap.createBitmap(imageBitmap, 0, 0, PREVIEW_WIDTH, PREVIEW_HEIGHT, rotateMatrix, false)
Related