[英]Defining an area for a screen capture on android
I currently have a VirtualDisplay
set up using the MediaProjection
API which is being drawn on to a SurfaceView
that is always visible.我目前使用MediaProjection
API 设置了VirtualDisplay
,它被绘制到始终可见的SurfaceView
上。 The VirtualDisplay is, however, capturing the entire display but I would like it do capture only the portion of which the SurfaceView is covering.然而,VirtualDisplay 正在捕获整个显示,但我希望它只捕获 SurfaceView 覆盖的部分。 Is there any solution to this, I would appreciate the help?有什么解决办法吗,不胜感激?
Thanks to this question, I have found a solution.感谢这个问题,我找到了解决方案。 Setting the SurfaceView
's scale was the key:设置SurfaceView
的比例是关键:
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.至于比例因子,我目前正在尝试反复试验,直到完美契合并与背景完美融合,但我会尝试以更加程序化和精确的方式进行。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.