Home » Android » java – How to slice & reverse camera view?

java – How to slice & reverse camera view?

Posted by: admin May 14, 2020 Leave a comment

Questions:

I am working on an app that will show reverse view from camera. For example, if current view from camera is like:
enter image description here,

the app should reverse view like:
enter image description here

so user will see constantly reverse view from camera through this app.

I am not very sure how to achieve this. Any help or idea would be highly appreciated. Thanks!

How to&Answers:

I understand from your answer that you want to display the reversed view in real-time.

I would create a custom SurfaceView and override the onDraw method to split the image in two and reverse the two slices.

Then I would pass the holder of your surface to the camera object like this:

camera.setPreviewDisplay(myCustomSurfaceView.getHolder());

Answer:

What about simply drawing only half your image at a time?

Create a custom component and override the onDraw. When you draw your bitmap, simply adjust the location and width values so you are only drawing half of the image at a time… of course you will need to draw twice.

You could also do the same thing with a second bitmap.. apply only part of your original bitmap to the second bitmap and do that twice, adjusting the location and width as needed.

Other options are to do some sort of transform, but my guess in the end is that your going to be doing something similar.