Defining an area for a screen capture on android

432 Views Asked by At

I currently have a VirtualDisplay set up using the MediaProjection API which is being drawn on to a SurfaceView that is always visible. The VirtualDisplay is, however, capturing the entire display but I would like it do capture only the portion of which the SurfaceView is covering. Is there any solution to this, I would appreciate the help?

enter image description here

1

There are 1 best solutions below

0
On

Thanks to this question, I have found a solution. Setting the SurfaceView's scale was the key:

mSurface.setScaleX(/*scale factor*/);
mSurface.setScaleY(/*scale factor*/);

As for the scale factors, I am currently trying with trial and error until I get a perfect fit and it blends in perfectly with the background, but I will try to do it in a more programmatic and precise manner.